【问题标题】:isInside not working for btConvexHullShape of Bullet Physics libraryisInside 不适用于 Bullet Physics 库的 btConvexHullShape
【发布时间】:2015-08-30 14:03:45
【问题描述】:

我使用 .obj 文件创建了一个 btConvexHullShape。我检查了它的其他属性,它似乎创建正确。

现在我必须执行碰撞检测检查。为此,我需要使用 isInside 函数。但无论该点在内部还是外部,它都会返回 False。

有人可以帮忙吗?

human = new btConvexHullShape();
	for (int i = 0; i < av->vertI; i++)
	{
		human->addPoint(btVector3(btScalar(av->vertices[i][0]), btScalar(av->vertices[i][1]), btScalar(av->vertices[i][2])));

	}

	CString s;
	btVector3 cx(0, -2, 1);
	if (human->isInside(cx, btScalar(1)))
	{
		OutputDebugString(L"True\n");
	}
	else
		OutputDebugString(L"False\n");

【问题讨论】:

    标签: collision-detection convex-hull bulletphysics


    【解决方案1】:

    我在 C# 中使用 BulletSharp 重现了相同的问题。这是我的代码:

        // test isInside
        ConvexHullShape hull = new ConvexHullShape();
        hull.AddPoint(new Vector3(100,0,0));
        hull.AddPoint(new Vector3(100, 100, 0));
        hull.AddPoint(new Vector3(0, 100, 0))
        hull.AddPoint(new Vector3(0,0, 0));
        hull.AddPoint(new Vector3(50,50,100));
        bool checkInside = hull.IsInside(new Vector3(50, 50, 50), 1);
    

    checkInside 为假,而点 {50,50,50} 在凸包内。 我查了BtConvexHullShape class implemententation。貌似IsInside函数还没有实现,总是返回false。

        //not yet
        bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
        {
             btAssert(0);
             return false;
        }
    

    我自己做了一些谷歌搜索,找到了一个用于三角形网格对象的IsInside() implementation。建议的解决方案使用光线投射。我还没有测试过代码,但它看起来很有希望。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多