DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D

Home Page:http://www.reactphysics3d.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RigidBody::raycast gives incorrect result in raycastInfo for body with multiple colliders + solution

VitorioK opened this issue · comments

bool isHit = body->raycast(ray, raycastInfo); - gives incorrect results in raycastInfo

Solution
File: Collider.cpp
Wrap results calculation in if(...) {}:
bool Collider::raycast(const Ray& ray, RaycastInfo& raycastInfo) {
...
// Convert the raycast info into world-space
if (isHit)
{
raycastInfo.worldPoint = localToWorldTransform * raycastInfo.worldPoint;
raycastInfo.worldNormal = localToWorldTransform.getOrientation() * raycastInfo.worldNormal;
raycastInfo.worldNormal.normalize();
}
...
}

Hello. Thanks for your feedback.
I am not sure I understand. Do you mean that the Body::raycast() method returns the raycast result in local-space of the body instead of world-space?