In these pull requests, I wrote test cases for several collision scenarios between different solids. In addition, I provide a foundation for future contributors, including myself, to easily write tests for collisions between any two solids.
Collision detection is essential in a game engine. It is the reason you go bonkers playing Flappy Bird. However, it would be difficult and expensive to represent each object using its exact geometry, so a better idea would be to put those objects in bounding volumes or CollisionSolids. These CollisionSolids are mathematically defined, so by using some math, a collision system would be able to detect their intersections with each other. Additional information on the collision should be provided, including the point of intersection and the vector normal to the contact (to push back on).
Currently, Panda3D is missing 3 collision tests: parabola into box, parabola into inverse sphere, box into capsule. Here are some use cases that we've probably seen before:
My second goal would be to add another CollisionSolid named CollisionHeightfield. The idea is that we can represent heightfields using a grayscale image, with lighter (taller) and darker (lower) pixels. We can use this concept to efficiently deal with collisions in uneven terrain, rather than representing the terrain as individual CollisionPolygons.
Since part of the project is figuring out the algorithms to use, this section consists of investigation on existing collision tests in Panda3D, and how they can be used as bases. At the end, I give a Minimal-Viable-Product outline of CollisionHeightfield.
Currently, there exists a Parabola into Sphere test, which splits the Parabola into tiny line segments and checks if they intersect the Sphere. Implementing Parabola into InvSphere will use the previous method as a basis, but needs further investigation on how it differs from the regular Sphere. I also have to keep in the mind edge cases, which includes the Parabola being entirely inside the bubble, or entirely outside.
Since the Box is not quadratic, the previous method is not necessary. The Parabola into Box test might resemble the Parabola into Polygon test, which uses the Parabola into Plane test. The Parabola into Plane test uses a quadratic equation, implementation can be found here. Edge cases include the Parabola being entirely inside the Box.
This one I'm not too sure about. For inspiration, I've taken a look at Ericson's chapter on Sphere-Swept Volumes as well as Capsule into Box and Box into Sphere (Arvo's Algorithm), but further investigation is required.
Week | Dates (Mon - Sun) | Description |
---|---|---|
Community Bonding | 05/06 - 05/27 |
|
Phase 1 | ||
1 | 05/27 - 06/02 |
|
2 | 06/03 - 06/09 |
|
3 | 06/10 - 06/16 |
|
4 | 06/17 - 06/23 |
|
Phase 2 | ||
5 & 6 | 06/24 - 06/30 07/01 - 07/07 |
|
7 & 8 | 07/08 - 07/14 07/15 - 07/21 |
|
Phase 3 | ||
9 & 10 | 07/22 - 07/28 07/29 - 08/04 |
|
11 & 12 | 08/05 - 08/11 08/12 - 08/19 (Monday) |
|
One the most challenging aspect of this project is that it requires an understanding of 3D space and linear algebra. I do have a introductory understanding of 3D space, but I will have to self-study some linear algebra. Thankfully, the Collision Detection Book has an overview of the math required for this project, which will be very useful. I will be utilizing the book and other online resources to prepare myself with the math required for this project.