Advertisement
bubuche

doom physic based on tesselation

Apr 17th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1.  
  2. Algorithm so far
  3.  
  4. We have a quadtree that will pre-filter elements.
  5. The quadtree only knows about AABB (Axis Aligned Bounding Box).
  6. It associates an AABB with an ELEMENT, which is
  7. 1) a type and
  8. 2) an id.
  9.  
  10. There is right now two kind of type: TRIANGLE and LINEDEF
  11. When the type is TRIANGLE, the id refers to a triangle in the tesselation.
  12. When the type is LINEDEF, the id refers to a linedef in the map.
  13.  
  14. As the tesselation is not an array but an array of array, there is a trick when the type is TRIANGLE : we have an array of pairs of index.
  15. The id is an index into this array.
  16.  
  17.  
  18. That being said, the two type have also two differents meaning.
  19. When the type is TRIANGLE, we only perform two tests:
  20. 1) is the center of the AABB inside the triangle ?
  21. 2) is the center of the triangle inside the AABB ?
  22.  
  23. Iff the answer of any of these questions is "yes", then we record the thing as being "in this sector".
  24.  
  25. When the type is LINEDEF, we check if the AABB actually intersects (or contains) the linedef.
  26. Iff the answer is yes we check if this movement is valid. This mean:
  27. 1) If both linedef's sides have a sector
  28. 2) If both linedef's side's sector's floor's height is "not to high".
  29.  
  30. Now, you maw wonder "why don't you perform a complete collision test when the type is TRIANGLE ?".
  31. Well, here are the different cases:
  32. 1) the AABB is entirely inside the triangle => check the center is enough
  33. 2) the triangle is entirely inside the AABB => check the center is enough
  34. 3) the triangle is entirely outside the AABB => no intersection anyway.
  35. 4) the AABB is crossing the triangle.
  36.  
  37. In this last case, several sub-cases:
  38. 1) the AABB is crossing a triangle side which happens to be a linedef => there will handled with other LINEDEF
  39. 2) the AABB is crossing only non-linedefs.
  40.  
  41. This 2) means that an other triangle of the SAME sector contains the center of the AABB, because non-linedef side only exists between triangles of the same sector.
  42.  
  43. The reason why we use the center (for both triangle and AABB) is that
  44. 1) it is easy to calculate
  45. 2) it avoid rounding problems
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement