Hi guys,
So apparently, the raycast function returns via an out parameter a RayCastResult which references a BroadPhaseEntry. Is there a way to get to the collider the raycast hit as an entity?
Eternal thanks!
Dechcaudron
Can I get an instance of an Entity via raycast?
-
- Posts: 7
- Joined: Thu Jul 10, 2014 8:52 am
Re: Can I get an instance of an Entity via raycast?
Yup; attempt to cast the BroadPhaseEntry to an EntityCollidable, then check the Entity property.
Some background to explain this: entities do not live in the broad phase directly. The "Entity" class handles the dynamics side of things, while BroadPhaseEntry objects are strictly for collision detection. So, the Entity owns a BroadPhaseEntry in the form of an EntityCollidable which acts as its collision proxy within the broad phase and subsequent collision detection pipeline. In contrast, things like the StaticMesh are BroadPhaseEntry objects directly since they don't do anything but produce collisions.
Some background to explain this: entities do not live in the broad phase directly. The "Entity" class handles the dynamics side of things, while BroadPhaseEntry objects are strictly for collision detection. So, the Entity owns a BroadPhaseEntry in the form of an EntityCollidable which acts as its collision proxy within the broad phase and subsequent collision detection pipeline. In contrast, things like the StaticMesh are BroadPhaseEntry objects directly since they don't do anything but produce collisions.
-
- Posts: 7
- Joined: Thu Jul 10, 2014 8:52 am
Re: Can I get an instance of an Entity via raycast?
Hi Norbo,
thanks a lot. It takes a while to learn how to use a PhysicsEngine decently and I'm struggling to learn several things at the same time. So I am guessing that if I wanted to check collisions that do now produce physical response (what Unity calls a trigger collider) a BroadPhaseEntry would be the way to do it?
Also, and a going a bit off-topic, may I ask why you developed this Engine? How many people do you have in your team?
Thanks a lot,
Dechcaudron
thanks a lot. It takes a while to learn how to use a PhysicsEngine decently and I'm struggling to learn several things at the same time. So I am guessing that if I wanted to check collisions that do now produce physical response (what Unity calls a trigger collider) a BroadPhaseEntry would be the way to do it?
Also, and a going a bit off-topic, may I ask why you developed this Engine? How many people do you have in your team?
Thanks a lot,
Dechcaudron
Re: Can I get an instance of an Entity via raycast?
A BroadPhaseEntry would be at least involved, yes.So I am guessing that if I wanted to check collisions that do now produce physical response (what Unity calls a trigger collider) a BroadPhaseEntry would be the way to do it?
The easiest approach is to take an entity and change its Entity.CollisionInformation.CollisionRules. For example, setting:
Code: Select all
Entity.CollisionInformation.CollisionRules.Personal = CollisionRule.NoSolver;
CollisionRules are also available for non-entities, like the StaticMesh.
More information about collision rules can be found here. Some examples can be found in some of the BEPUphysicsDemos (CollisionFilteringDemo, EntityConstructionDemo, TankDemo, RagdollDemo, and a few others).
Technically, it's also possible to create your own BroadPhaseEntry type and then do just about anything, but that tends to be more work.
I could cleverly rationalize my former self's actions by saying:Also, and a going a bit off-topic, may I ask why you developed this Engine?
1) If we're going full managed for later projects, it would be tedious to deal with the interop layers to an existing native solution.
2) A custom solution gives us more freedom in modification for both features and performance.
3) A from-scratch implementation offers lots of educational potential.
4) The potential revenue from productizing it could be useful for launching the later planned projects.
Other than #4, all of these were at least partially true, but they don't really feel like the reason I spent so much time making a physics engine. The real reason probably sounds more like "I played with legos and jenga blocks a lot", plus an obsession with simulation of various kinds.
Bepu Entertainment is a duo, but I'm the sole developer of BEPUphysics specifically. Squashwell works on other stuff.How many people do you have in your team?
-
- Posts: 7
- Joined: Thu Jul 10, 2014 8:52 am
Re: Can I get an instance of an Entity via raycast?
Wow, that documentation page is gold. I know I had a look at it some days ago, but I did not remember about it at all.
I am so impressed you made this yourself. The real reason sounds perfectly good to me, but I am even more impressed that you made this free and open to everyone. You have my gratitude, sir. I wish my current project can generate earnings so I can give something to you as a personal reward (I swear I have a goddamn list of people I owe rewards to for helping me learn for free).
Keep it up Norbo, you rule
Dechcaudron
I am so impressed you made this yourself. The real reason sounds perfectly good to me, but I am even more impressed that you made this free and open to everyone. You have my gratitude, sir. I wish my current project can generate earnings so I can give something to you as a personal reward (I swear I have a goddamn list of people I owe rewards to for helping me learn for free).
Keep it up Norbo, you rule
Dechcaudron