# Extending Panda3D's Collision System

Hello Panda3D community! This summer, I am participating in Google Summer of Code and will be adding the following features to Panda3D’s collision detection system:

• Parabola into Box detection
• Parabola into Inverse Sphere detection
• Box into Capsule detection
• Implement a Heightfield class for collision with uneven terrains

You can find my full proposal here, which includes a timeline with implementation details. The coding period has begun, and this first week I have made my attempt at Parabola into Box, which you can find here. Stay tuned for my weekly updates!

4 Likes

The second week of GSoC has passed, and it was quite a busy one. Last week, I proposed a simple algorithm for Parabola into Box: iterate through the six planes of the Box and test for intersection with the parabola. Turns out, this algorithm was a bit too simple. After discussion with my mentors, I realized that the intersection point has to be behind all other planes of the box for a collision to exist. I spent a good part of Week 2 fixing my algorithm. One obstacle I came across was that at the corner of the box, it did not seem to pass my collision test. After talking to my mentors, I realized that it was only a matter of perspective. By using a different lens I confirmed that it was working correctly. After updating my pull request the algorithm is now merged!

For the second half of Week 2, I worked on Parabola into Inverse Sphere. As usual, I started off by writing some unit tests. This time, I made a test program (based off of my mentor’s) to visualize the parabola and inverse sphere. I implemented the following algorithm: recursively subdivide the parabola into “close-enough” line segments, and test their intersection with the sphere. After passing all tests and appearing to be correct using the visualizer, I submitted a pull request for discussion and review.

Next week, I am scheduled to work on Box into Capsule detection. Check back for more updates!

1 Like

Hello everyone! It has been a while since my last update, so I’m excited to share with you guys everything that has happened thus far. First, the parabola-into-invsphere test I mentioned last post is now merged! Also, I submitted a PR for box-into-capsule test, which you can find here.
I am also excited to announce that the CollisionHeightfield is currently under development! Based off of Tim Sjostrand’s “Efficient Intersection of Terrain Geometry in Real-Time Applications”, the implementation using a quadtree data structure to efficiently test for intersections with the terrain. Currently, I have set up the quadtree and am finishing up a ray-terrain collision test. I am looking forward to implementing box-terrain and sphere-terrain intersection tests. In general, these tests will resemble a box intersection test and then a triangle intersection test. To see my progress and for more information on implementation, you can check my branch on Github. See you next week!

2 Likes

Hello all, welcome to another update! This past month, I have been working on the `CollisionHeightfield` class, and am happy to announce that it currently has collision tests for rays, spheres, and boxes. My next step is to finalize everything by testing extensively, adding documentation, and improving the collision tests. I also need to make sure that it is compatible with all of Panda3D’s available terrain renderers, including `GeoMipTerrain`, `HeightfieldTesselator`, and `ShaderTerrainMesh`. Currently, I am visualizing the collisions using `GeoMipTerrain`, and so far it is looking good. If time allows, I would also like to create a sample game, that will showcase the `CollisionHeightfield`, something like Roaming Ralph. If you would like to follow my progress, you can take a peek at my draft pull request at https://github.com/panda3d/panda3d/pull/691. Lastly, my box-into-capsule collision test has been merged! That is all for this week, I will post another update soon, see you then!

2 Likes

That sounds like pretty good work–well done, and I’m glad to read of it!

1 Like

I’m eagerly looking forward to try it! As in Cosmonium height maps are used extensively, being able to to collision testing with height field is something very much needed

Will one be able to do collision testing with arbitrary height field (stored in a texture for example) or one of the Panda terrain must be used ?

1 Like

Thanks, I’m just as excited! You need only to pass a `PNMImage` to `CollisionHeightfield` for it to function, so theoretically no terrain actually needs to be rendered.