日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Bullet 物理引擎 详细分析 Dbvt (4)

發布時間:2025/7/14 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Bullet 物理引擎 详细分析 Dbvt (4) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

光線與AABB 相交檢測:
這是一個非常經典的問題, <<real time collision detection>> 5.33章節有非常詳盡的討論。
下面是光線的方程

?? t是可變參數, P是光線的起始點 RayFrom, d是光線的方向向量

下面這個是平面的方程

??

向量n是平面的法向量,所以如果光線與任何一個平面相交,應該有如下等式

?

對于AABB來說是六個平面, 每個面的法向量為(0,0,1)(0,1,0) ..... 總之三個坐標有兩個是0,另外的一個是1或者-1
AABB同時是3個平面槽的交集, 光線與AABB最多有2個相交點,一個是前景點,一個后景點,分別與兩個平面相交。
特例是完全與一個平面重合。可以被認為是和相鄰的兩個平面相交。
btRayAabb2.是bullet中用于檢測的相關函數

view plaincopy to clipboardprint?
SIMD_FORCE_INLINE bool btRayAabb2(const btVector3& rayFrom,? // point P??
const btVector3& rayInvDirection,? // Direction Vector inverse??
const unsigned int raySign[3],??
const btVector3 bounds[2],??? // min x, max x AABB volume??
btScalar& tmin,??
btScalar lambda_min,??
btScalar lambda_max)??
{??
btScalar tmax, tymin, tymax, tzmin, tzmax;??
// get the far plane intersect param t along x axis??
tmax = (bounds[1-raySign[0]].getX() - rayFrom.getX()) * rayInvDirection.getX();??
// get the near plane intersect param t along y axis??
tymin = (bounds[raySign[1]].getY() - rayFrom.getY()) * rayInvDirection.getY();??
// get the far plane intersect param t along y axis??
tymax = (bounds[1-raySign[1]].getY() - rayFrom.getY()) * rayInvDirection.getY();??
// if it is not intersect with any plane then exit??
if ( (tmin > tymax) || (tymin > tmax) )??
return false;??
if (tymin > tmin)??
tmin = tymin;? // update the tmin??
if (tymax < tmax)??
tmax = tymax; // update tmax??
// get the near plane intersect param t along Z axis??
tzmin = (bounds[raySign[2]].getZ() - rayFrom.getZ()) * rayInvDirection.getZ();??
// get the far plane intersect param t along Z axis??
tzmax = (bounds[1-raySign[2]].getZ() - rayFrom.getZ()) * rayInvDirection.getZ();??
// if it is not intersect with any plane then exit??
if ( (tmin > tzmax) || (tzmin > tmax) )??
return false;??
// caculate the interval??
if (tzmin > tmin)??
tmin = tzmin;?? // if find nearer point update tmin??
if (tzmax < tmax)??
tmax = tzmax;?? // if found the farer point update tmax??
return ( (tmin < lambda_max) && (tmax > lambda_min) );??
}?
SIMD_FORCE_INLINE bool btRayAabb2(const btVector3& rayFrom,? // point P
const btVector3& rayInvDirection,? // Direction Vector inverse
const unsigned int raySign[3],
const btVector3 bounds[2],??? // min x, max x AABB volume
btScalar& tmin,
btScalar lambda_min,
btScalar lambda_max)
{
btScalar tmax, tymin, tymax, tzmin, tzmax;
// get the far plane intersect param t along x axis
tmax = (bounds[1-raySign[0]].getX() - rayFrom.getX()) * rayInvDirection.getX();
// get the near plane intersect param t along y axis
tymin = (bounds[raySign[1]].getY() - rayFrom.getY()) * rayInvDirection.getY();
// get the far plane intersect param t along y axis
tymax = (bounds[1-raySign[1]].getY() - rayFrom.getY()) * rayInvDirection.getY();
// if it is not intersect with any plane then exit
if ( (tmin > tymax) || (tymin > tmax) )
return false;
if (tymin > tmin)
tmin = tymin;? // update the tmin
if (tymax < tmax)
tmax = tymax; // update tmax
// get the near plane intersect param t along Z axis
tzmin = (bounds[raySign[2]].getZ() - rayFrom.getZ()) * rayInvDirection.getZ();
// get the far plane intersect param t along Z axis
tzmax = (bounds[1-raySign[2]].getZ() - rayFrom.getZ()) * rayInvDirection.getZ();
// if it is not intersect with any plane then exit
if ( (tmin > tzmax) || (tzmin > tmax) )
return false;
// caculate the interval
if (tzmin > tmin)
tmin = tzmin;?? // if find nearer point update tmin
if (tzmax < tmax)
tmax = tzmax;?? // if found the farer point update tmax
return ( (tmin < lambda_max) && (tmax > lambda_min) );
}

現在可以討論ayTestInternal 函數, 這個函數基本的算法就是遍歷所有的節點(基于棧)
光線講和樹中的每個節點做相交測試,如果相交就繼續處理對應的子結點,否則就跳過。
對應所有最終的相交葉子節點,調用相交處理邏輯(回調函數)來處理。

view plaincopy to clipboardprint?
do?
{??
//pop out the top of stack??
const btDbvtNode* node=stack[--depth];??
//set up the AABB BOX??
bounds[0] = node->volume.Mins()-aabbMax;??
bounds[1] = node->volume.Maxs()-aabbMin;??
btScalar tmin=1.f,lambda_min=0.f;??
unsigned int result1=false;??
// Do the intersect tes t!!??
result1 = btRayAabb2(rayFrom,rayDirectionInverse,??
signs,bounds,tmin,lambda_min,??
lambda_max);??
if(result1)??
{??
//if test pass??
if(node->isinternal())??
{ //if node is intertal??
if(depth>treshold) //dynamic expand stack??
{??
stack.resize(stack.size()*2);??
treshold=stack.size()-2;??
}??
//push the left child into stack??
stack[depth++]=node->childs[0];??
//push the right child into stack??
stack[depth++]=node->childs[1];??
}??
else?
{??
//if node is leaf node,then process it by callback??
policy.Process(node);??
}??
}??
} while(depth);?

?

本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/superwiles/archive/2010/03/16/5383896.aspx

轉載于:https://www.cnblogs.com/lancidie/archive/2011/03/02/1968585.html

總結

以上是生活随笔為你收集整理的Bullet 物理引擎 详细分析 Dbvt (4)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 2024国产精品 | 中文字幕狠狠干 | 免费毛片网 | 色图自拍| 欧美污视频| www.三级.com | 欧美日韩精品在线观看 | 国产性生活网站 | 最近免费中文字幕中文高清百度 | 东京av男人的天堂 | 国产精品视频一区二区三区 | 欧美整片在线 | 91porny丨首页入口在线 | 91久久电影| 国产精品秘入口18禁麻豆免会员 | 黄色特级片 | 四虎8848精品成人免费网站 | www.日日操 | 色屁屁www | 啪啪网站免费看 | 日日骑夜夜操 | 亚洲精品在线免费播放 | 亚洲看看 | 超碰caoporen | 久久国产精 | 男女交性视频 | 亚洲一区二区 | www.亚洲高清 | 欧美日韩一区二区三区不卡 | 午夜污| 日日干夜夜拍 | 成年免费视频黄网站在线观看 | 国产一区二区小视频 | 成人在线一区二区 | 久久久高清 | 男男成人高潮片免费网站 | 国产叼嘿视频在线观看 | 国产成人精品网 | 久久久久久久久久一区二区 | 美女搡bbb又爽又猛又黄www | 午夜久久久久 | 91视频免费网站 | 日韩欧美国产一区二区在线观看 | 免费网站成人 | 欧美性受xxxxxx黑人xyx性爽 | 侵犯女教师一区二区三区 | 波多野结衣中文字幕在线 | av大全在线 | 闺蜜张开腿让我爽了一夜 | 欧美精品亚洲 | 成人国产免费观看 | 国产精品美女一区二区三区 | 青青草公开视频 | 大桥未久恸哭の女教师 | www.激情网 | 亚洲国产tv | 99精品视频在线播放免费 | 午夜小视频网站 | 视色视频 | 免费精品久久 | 久久久资源 | 亚洲成人中文字幕 | 日韩一级免费看 | 国产午夜视频 | 国产高潮视频 | 韩国伦理在线视频 | 久久久久久网址 | 免费看裸体视频网站 | 日韩黄色三级 | 在线色av| 亚洲精品国产无码 | 中国无码人妻丰满熟妇啪啪软件 | 人人爽人人干 | 狠狠干狠狠干狠狠干 | 四虎精品欧美一区二区免费 | 国产欧美一区二区三区白浆喷水 | 日韩中文字幕免费视频 | 亚洲av色一区二区三区精品 | 任你操精品视频 | 欧美福利一区二区三区 | av电影网站在线观看 | 91成人在线观看喷潮蘑菇 | 每日av在线 | www.好吊色 | 亚洲综合五月天 | 生活片av | 亚洲av色香蕉一区二区三区 | 91午夜视频 | 在线免费看黄色片 | 日韩在线观看免费全 | 国产日产亚洲精品 | 天天射天天干天天 | 美女的胸给男人玩视频 | 999精品视频在线观看 | 日韩精品乱码 | 在线免费观看黄色av | 欧美精品一区二区三区久久久 | 亚洲日本国产 | 欧美激情一区二区三区在线 |