Page 1 of 1

getCollisionPoint behaves strange

Posted: Thu Aug 27, 2009 8:12 am
by Bear_130278

Code: Select all

vector3df ColPoint;
triangle3df CT;

line3df checker(P.X,10000.0f,P.Z,P.X,-1000.0f,P.Z);
bool cFound=Core.smgr->getSceneCollisionManager()->getCollisionPoint(checker,Core.selector,ColPoint,CT);
So i have a custom scene node for terrain + triange selector made for it.
The problem is, that getCollisionPoint() not allways return true, when i'm ABSOLUTELY sure, that there IS a collision.
What possibly could be the problem?

P.S. Now i'll try to make a custom funcion from CTerrainSceneNode::getHeight(f32 x, f32 z) in order to check the stuff by hand.

Posted: Thu Aug 27, 2009 9:07 am
by U238
Are you sure that
1) Your terrain rotation is (0.0f, 0.0f, 0.0f);
2) Your terrian is not small enough to point (P.X,P.Z) be outsize it. Keep in mind that terrain HWD is not

Code: Select all

terrain->getScale() 
but

Code: Select all

terrain->getBoundingBox()->getExtent()
3) Your selector right set to terrain and is not NULL?

PS: By the way, hello, I'm from Russia ) What do you write? )

Posted: Thu Aug 27, 2009 1:04 pm
by Bear_130278
Хех Привет *))
Та на досуге балуюсь, пишу РПГ+РТС...

1. As i already said, i do not use terrainSceneNode, i have a customized plain mesh instead.
2. The problem is, that i have a fault not all the time, but let's say 1 fault on 100 checks.

Posted: Thu Aug 27, 2009 1:09 pm
by CuteAlien
Do you already use newest version? There was a problem in 1.5 which got fixed with 1.5.1.

If that doesn't solve it then we need a test-case so we can reproduce it.

Posted: Thu Aug 27, 2009 1:29 pm
by Bear_130278
CuteAlien, i'll try 151.
I got the same issue with 1.1 version also.
Update: The same 8(

Ok Look...
Here is the full function

Code: Select all

f32 Terrain::GetTerrainY(vector3df P)
{
f32 result=0.0f;
vector3df ColPoint;
triangle3df CT;

line3df checker(P.X,10000.0f,P.Z,P.X,-1000.0f,P.Z);
line3df checker2(P.X+5,-10000.0f,P.Z-5,P.X+5,10000.0f,P.Z-5);
bool cFound=Core.smgr->getSceneCollisionManager()->getCollisionPoint(checker,Core.selector,ColPoint,CT);

if(cFound==1)
{
	result=ColPoint.Y;result+=2.0f; // This check fails randolmly
}
else
{
// If the first one failed i just use the checker2 line whitch is almost the same, but with +5.0f offset to the original
	cFound=Core.smgr->getSceneCollisionManager()->getCollisionPoint(checker2,Core.selector,ColPoint,CT);
	if(cFound==1)
	{
		result=ColPoint.Y;result+=2.0f;// Most of the time this second check returns true.... but not ALL the time...
	}
	else
	{
		result=300;// If failed i return stupid number, just to know that we failed....
	}
}

return result;
}

Posted: Thu Aug 27, 2009 1:51 pm
by U238
Я тоже что-то пописываю. ) Пришла идейка - теперь вымучиваю. Как у тебя идет? На какой стадии?

Posted: Thu Aug 27, 2009 2:34 pm
by Bear_130278
Updating was a baad idea? *)

Posted: Thu Aug 27, 2009 3:28 pm
by CuteAlien
The function looks fine to me (though you shouldn't really check bools for == 1 but for == true even if it works on many systems).

But that function is not enough so we can reproduce it. Can't you make a complete test-case which can be compiled?

Otherwise - if you didn't already do so, then start drawing debug-lines to be sure the lines are really where you expect them to be. And if that still looks fine, well unless you can give us a testcase you will have to debug it.

Posted: Thu Aug 27, 2009 3:33 pm
by Bear_130278
Very easy....
GetTerrainY(vector3df P) // P here is just an absolute position of the char node.
Core.selector is any selector for the big plain mesh
10000x10000, 20000 tris

Oooohhh lazy me....
Good i'll make a test app for this poop 8))

Posted: Thu Aug 27, 2009 4:13 pm
by hybrid

Posted: Thu Aug 27, 2009 5:25 pm
by CuteAlien
hybrid wrote:Could be due to this bug: https://sourceforge.net/tracker/?func=d ... tid=540676
Hm, yeah, sounds rather similar.