Skip to content

Collision

bluecri edited this page Sep 29, 2018 · 12 revisions

Collision

Imgur

CollisionComponent

  • Has ReadWrite Lock for tbb, Rigidbody, Category MaskBit

  • Get Component from CollisionManager

  • Parent is VectorPElem

  • Has index of octreeElem vector


AABB, Sphere, OBB CollisionCompnent

  • Has local position(OBB : mat4, other : vec3)

  • Has shape class (AABB, OBB, Sphere)

Sphere : vec3 worldPos, float radius

AABB : vec3 worldPos, vec3 halfAxisLen

OBB : mat4 worldPos, vec3 halfAxisLen


OBBCollisionComponent

  • Has AABB covers OBB with any quaternion for slight collision detection


Octree

  • Has octree elem vector

  • Update collision component in octree

Collision Component update with TBB parallel_do

Check Comp is sleep or delete and push to sleep container

Check Comp is in Same OctreeElem. If not, reinsert comp to octree root

Insert new & sleep Collision Component or remove component

If Component is in octreeElem & octreeElem has children, check comp is in children recursively.

If OctreeElem has more component than threshold, use children and propagate comps to children


OctreeElem

  • Has 8 OctreeElem children, Collision component threshold

  • Use potential collision list when check collision detection


Collision Detection with TBB

  • Try collision detection on all OctreeElem

Find all potential components of current octreeElem & compare with current potential components

Use TBB parallel_for

Check collision category mask bit and trigger.

If collision is occurred, get TBB_writeLock & save collision component to other component for game logic

If collision reaction is needed, push to resolveCompVec(concurrentVector)


Collision Resolve


VectorP, VectorPElem

  • Elem has index of vector. If removed, last elem replaces removed index.

  • Cons : Used as composite not inheritance

Clone this wiki locally