[bug] Portal::calcDirectionAndRadius doesn't scale

jmd

26-04-2009 21:38:24

Hi,

First i'd like to apologize for the fact that I don't have a patch for this bug. I'm currently in the rush to finish my school project and I don't have to time to implement a generic solution to this.

Here's the problem:
My portal was way to big even though I validated my coordinates using a ManualObject to represent it and my ManualObject was fitting perfectly where it should.
The problem is that my interior SceneNode is scaled at 0.22 and the Portal::calcDirectionAndRadius doesn't take into account the scale of the node containing the portal. I use quads for my portal and to fix this problem, I hardcoded my scale in the mRadius calculation.

Here's where I added my scale:

void Portal::calcDirectionAndRadius(void)
{
Vector3 radiusVector;
Vector3 side1, side2;

switch (mType)
{
default:
case PORTAL_TYPE_QUAD:
// first calculate local direction
side1 = mCorners[1] - mCorners[0];
side2 = mCorners[2] - mCorners[0];
mDirection = side1.crossProduct(side2);
mDirection.normalise();
// calculate local cp
mLocalCP = Vector3::ZERO;
for (int i=0;i<4;i++)
{
mLocalCP += mCorners[i];
}
mLocalCP *= 0.25f;
// then calculate radius
radiusVector = mCorners[0] - mLocalCP;
mRadius = radiusVector.length();
mRadius *= 0.22f; // <- MY HARDCODED SCALE
break;
case PORTAL_TYPE_AABB:
// ...


Again, I'm sorry I don't have the time to come with a generic solution but I hope this might help someone having the same problem.
It's probably something as simple as :

mRadius *= mNode->_getDerivedScale().x; // or y, or z?


Thanks,

JM