zoukankan
html css js c++ java
光线与球的求交代码
//
-------------------------------------------------------------------------
eiBool eiSphere::intersect(eiRay
*
ray, eiObject
*
po, eiFloat
&
oldt,
eiPrimitive
* &
ret_pri, eiFloat
*
cust_data,
HitParam
*
hparam)
{
if
( oldt
==
0.0f
||
ray_box( ray
->
src, hparam
->
hitPoint )
{
//
compute intersecting point
eiVector oc
=
add( ray
->
src,
-
center );
eiFloat oc_len
=
dist( oc );
if
( oc_len
>
radius
||
po
->
material
->
doubleSide )
{
eiFloat a
=
dot( ray
->
dir, ray
->
dir );
eiFloat b
=
2.0f
*
dot( oc, ray
->
dir);
eiFloat c
=
dot( oc, oc )
-
RR;
eiFloat dt
=
b
*
b
-
4.0f
*
a
*
c;
eiFloat t;
if
(a
==
0.0f
||
dt
<
0.0f
)
return
false
;
else
if
(dt
==
0.0f
)
{
t
=
-
b
/
a
*
0.5f
;
if
(t
<
0.0f
)
return
false
;
}
else
{
a
=
0.5f
/
a;
eiFloat t1
=
(
-
b
+
sqrtf( dt ))
*
a;
eiFloat t2
=
(
-
b
-
sqrtf( dt ))
*
a;
if
(t1
>
0.0f
&&
t2
<
0.0f
)
t
=
t1;
else
if
(t1
<
0.0f
&&
t2
>
0.0f
)
t
=
t2;
else
if
(t1
>
0.0f
&&
t2
>
0.0f
)
t
=
(t1
<
t2)
?
t1 : t2;
else
return
false
;
}
eiVector tmpIntersection
=
add(ray
->
src, mulvf(ray
->
dir,t));
//
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
return
true
;
}
}
}
return
false
;
}
查看全文
相关阅读:
ctfhub技能树—信息泄露—备份文件下载—vim缓存
ctfhub技能树—信息泄露—备份文件下载—bak文件
ctfhub技能树—信息泄露—备份文件下载—网站源码
RecyclerView错误
R.java的生成规则
各种编译不通过xcode
Gradle
xcode如何运行下载的demo工程
xcode资源管理
IOS代码片段
原文地址:https://www.cnblogs.com/len3d/p/202305.html
最新文章
Bugku-CTF之输入密码查看flag
Bugku-CTF之看看源代码吧
Bugku-CTF之管理员系统+程序员本地网站
Bugku-CTF之网站被黑(这个题没技术含量但是实战中经常遇到)
Bugku-CTF之Web5(JSPFUCK??????)
Bugku-CTF之变量1
Bugku-CTF之你必须让他停下+头等舱
Bugku-CTF之域名解析(听说把 flag.baidu.com 解析到123.206.87.240 就能拿到flag)
Bugku-CTF之web3-flag就在这里快来找找吧
Bugku-CTF之矛盾
热门文章
Bugku-CTF之web基础$_POST
Bugku-CTF之web基础$_GET
Bugku-CTF之flag.php(点了login咋没反应)
CTFshow萌新赛-千字文
CTFshow-萌新赛杂项_劝退警告
CTFshow-萌新赛web_假赛生
CTFshow萌新赛-web签到
CTFshow萌新赛-密码学签到
CTFshow-萌新赛杂项_签到
ctfhub技能树—信息泄露—备份文件下载—.DS_Store
Copyright © 2011-2022 走看看