Bug in InteriorInstance::castRay()
by Tom Spilman · in Torque Game Engine Advanced · 05/02/2006 (2:22 pm) · 2 replies
This is a bug that's been in TSE since my first checkout in Dec 2004:
As you can see InteriorInstance::castRay() is transforming the normal into world space. Well the problem is that Container::castRay() also transforms the normal... so your hit normals are transformed twice for hits on interiors.
Looking at TGE 1.4 it does this properly:
bool InteriorInstance::castRay(const Point3F& s, const Point3F& e, RayInfo* info)
{
info->object = this;
if (mInteriorRes->getDetailLevel(0)->castRay(s, e, info)) {
PlaneF fakePlane;
fakePlane.x = info->normal.x;
fakePlane.y = info->normal.y;
fakePlane.z = info->normal.z;
fakePlane.d = 0;
PlaneF result;
mTransformPlane(getTransform(), getScale(), fakePlane, &result);
info->normal = result;
return true;
}
return false;
}As you can see InteriorInstance::castRay() is transforming the normal into world space. Well the problem is that Container::castRay() also transforms the normal... so your hit normals are transformed twice for hits on interiors.
Looking at TGE 1.4 it does this properly:
bool InteriorInstance::castRay(const Point3F& s, const Point3F& e, RayInfo* info)
{
info->object = this;
return mInteriorRes->getDetailLevel(0)->castRay(s, e, info);
}About the author
Tom is a programmer and co-owner of Sickhead Games, LLC.
Torque Owner Brian Ramage
Black Jacket Games