getCollisionPoint behaves strange

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Bear_130278
Posts: 237
Joined: Mon Jan 16, 2006 1:18 pm
Location: Odessa,Russian Federation

getCollisionPoint behaves strange

Post 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.
Do you like VODKA???
Image
Image
U238
Posts: 14
Joined: Mon Aug 17, 2009 1:01 pm
Location: Taganrog, Russia

Post 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? )
Bear_130278
Posts: 237
Joined: Mon Jan 16, 2006 1:18 pm
Location: Odessa,Russian Federation

Post 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.
Do you like VODKA???
Image
Image
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Bear_130278
Posts: 237
Joined: Mon Jan 16, 2006 1:18 pm
Location: Odessa,Russian Federation

Post 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;
}
Last edited by Bear_130278 on Thu Aug 27, 2009 1:58 pm, edited 1 time in total.
Do you like VODKA???
Image
Image
U238
Posts: 14
Joined: Mon Aug 17, 2009 1:01 pm
Location: Taganrog, Russia

Post by U238 »

Я тоже что-то пописываю. ) Пришла идейка - теперь вымучиваю. Как у тебя идет? На какой стадии?
Bear_130278
Posts: 237
Joined: Mon Jan 16, 2006 1:18 pm
Location: Odessa,Russian Federation

Post by Bear_130278 »

Updating was a baad idea? *)
Do you like VODKA???
Image
Image
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Bear_130278
Posts: 237
Joined: Mon Jan 16, 2006 1:18 pm
Location: Odessa,Russian Federation

Post 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))
Do you like VODKA???
Image
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

hybrid wrote:Could be due to this bug: https://sourceforge.net/tracker/?func=d ... tid=540676
Hm, yeah, sounds rather similar.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply