Jump to content

PhysicsIntersection with terrain


Recommended Posts

PhysicsIntersectionPtr intersection = PhysicsIntersection::create();
	// get an intersection
	Vec3 p1 = node->getWorldPosition();
	
	ter->setForceIntersection(1);
	ObjectPtr object = Physics::get()->getIntersection(lastPos,
		p1, 0x00000001,intersection);
	ter->setForceIntersection(0);

	NodePtr contactNode;
 
	if (object)
	{
      ...
    }
	lastPos = p1;

Sometimes contact with the terrain fails.

Is it because I didn't use worldIntersecion instead? Or is it due to the terrain material optimization option (Back Face Culling, Subpixel Polygons Reduce)?

Edited by dongju.jeong
Link to comment

Hello,

Hard to tell why. Do you see any patterns when intersection fails?

You also can try the following:

  1. Disable setForceIntersection and check how it influences the result
  2. Call this code from updatePhysics
  3. Use PhysicsIntersectionNormalPtr intersection = PhysicsIntersectionNormal::create(); instead PhysicsIntersectionPtr intersection = PhysicsIntersection::create();

Thanks.

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

well.. 

I experimented by implementing the code in the fired bullet.

It's different every time I run it, but if I find a failing location and fire a bullet at the same location, it always fails.

 

after try the method you gave me, I tell you again.

Thank you.

Edited by dongju.jeong
Link to comment
×
×
  • Create New...