c++ - osg::BoundingBox 交点偏移检测
问题描述
我需要在两个移动节点碰撞之前检查它们之间的交叉点。
我有这段代码,它有效,但只有当它们已经命中时它才是正确的。
有没有一种简单的方法可以给边界框一个偏移量,所以在它们击中之前它会给出真实的?
osg::ComputeBoundsVisitor cbv;
MatrixTransform* transform = new osg::MatrixTransform;
transform->addChild(node);
transform->accept(cbv);
osg::BoundingBox bb = cbv.getBoundingBox();
osg::ComputeBoundsVisitor cbv2;
MatrixTransform* transform2 = new osg::MatrixTransform;
transform2->addChild(node2);
transform2->accept(cbv2);
osg::BoundingBox bb2 = cbv2.getBoundingBox();
bool intersects=bb.intersects(bb2);
解决方案
You could manually use expandBy ( https://codedocs.xyz/openscenegraph/OpenSceneGraph/a01950.html#a4d779d1d6346bce5b3ae469c886a777f ) to increase the size of the bounding box. Take the existing XYZ min point, add your offset, and call expandBy. Repeat with the XYZ max point.
推荐阅读
- android - React Native Picker onValueChange 不会触发多行选择器项
- unity3d - Hololens2 Azure 空间锚教程崩溃
- django - “CreateView”对象没有属性“render_to_response”
- mysql - 如何从 PySpark 删除数据库表上的索引?
- c# - 在统一 3D 中更改 Cubical Shower 3d 模型的尺寸
- python-3.x - 无法从 sklearn.metrics 导入平均绝对百分比误差
- java - 使用 instanceof 并使用泛型进行强制转换
- installation - 无法在 Fedora 上安装 GridDB
- ios - 我可以强制或诱导 iOS 14 App Tracking Transparency 授权吗?
- c++ - 忽略预编译的头文件,我应该吗?