zoukankan
html css js c++ java
光线与三角的求交代码
eiBool eiTriangle::intersect(eiRay
*
ray, eiObject
*
po, eiFloat
&
oldt,
eiPrimitive
*
&
ret_pri, eiFloat
*
cust_data, HitParam
*
hparam)
{
if
( clip
==
EI_BSP_PRIMITIVE
&&
( oldt
==
0.0f
||
ray_box( ray
->
src, hparam
->
hitPoint ) )
)
{
//
compute intersecting point
eiFloat vnd
=
dot(normal , ray
->
dir);
if
(ray
->
type
==
RAY_SHADOW)
vnd
=
-
vnd;
if
( vnd
<
0.0f
||
po
->
material
->
doubleSide )
{
eiFloat t,td1,td2,td3;
eiVector tmpIntersection;
if
(ray
->
type
==
RAY_SHADOW)
t
=
( dot( normal , ray
->
src)
+
d )
/
vnd;
else
t
=
-
( dot( normal , ray
->
src)
+
d )
/
vnd;
if
(t
<
0.0f
)
return
false
;
tmpIntersection
=
add(ray
->
src, mulvf(ray
->
dir,t));
//
make sure intersection in bound box
if
(
!
is_pos_in_box(tmpIntersection, box))
return
false
;
//
near and far clipping
if
(ray
->
type
==
RAY_EYE
&&
!
near_far_clip(tmpIntersection))
return
false
;
//
is in triangular area
td1
=
dot(tmpIntersection , la)
+
d1;
if
(td1
<
0.0f
||
td1
>
1.0f
)
return
false
;
td2
=
dot(tmpIntersection , lb)
+
d2;
if
(td2
<
0.0f
||
td2
>
1.0f
)
return
false
;
td3
=
dot(tmpIntersection , lc)
+
d3;
if
(td3
<
0.0f
||
td3
>
1.0f
)
return
false
;
//
affect shadow factor
if
(ray
->
type
==
RAY_SHADOW)
hparam
->
shadow_factor
*=
1.0f
-
po
->
material
->
opacity;
//
find nearest hit point
if
(oldt
==
0.0f
||
t
<
oldt)
{
hparam
->
hitPoint
=
tmpIntersection;
hparam
->
hitObj
=
po;
ret_pri
=
this
;
oldt
=
t;
//
fill custom data
cust_data[
0
]
=
td1;
cust_data[
1
]
=
td2;
cust_data[
2
]
=
td3;
return
true
;
}
}
}
return
false
;
}
查看全文
相关阅读:
Optimizing Druid with Roaring bitmaps
Processing a Trillion Cells per Mouse Click
Fine-grained Partitioning for Aggressive Data Skipping
F1 Query: Declarative Querying at Scale
Data Blocks: Hybrid OLTP and OLAP on Compressed Storage using both Vectorization and Compilation
How to Architect a Query Compiler
Evaluating EndtoEnd Optimization for Data Analytics Applications in Weld
Everything You Always Wanted to Know About Compiled and Vectorized Queries But Were Afraid to Ask
Pinot: Realtime OLAP for 530 Million Users
JSP简单练习-猜字母游戏
原文地址:https://www.cnblogs.com/len3d/p/229157.html
最新文章
【算法】CRF(条件随机场)
【mongo】查询超时处理
【python】使用flask制作小型页面的关键点总结
Java的内存管理机制之内存区域划分
软考云题库上线了
一文读懂Spring中的DI和AOP
架构师之路—理解设计模式
架构师之路—从阅读经典开始
成长
我的北京工作居住证申请之旅
热门文章
企业应用架构的基本模式之分离接口
SOLDI原则之DIP:依赖倒置原则
企业应用架构的基本模式之入口模式
领域逻辑的组织模式
《金子塔原理》读书笔记之解决问题的逻辑
多线程的风险漫谈
初识Spring Boot
微信iOS客户端升级内核对自定义分享的影响
阿里云数据库团队校园春季招聘
列存格式
Copyright © 2011-2022 走看看