// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #pragma once #include #include #include namespace anki { /// Wrapper on top of JPH collision shapes. class PhysicsCollisionShape : public PhysicsObjectBase { ANKI_PHYSICS_COMMON_FRIENDS friend class PhysicsCollisionShapePtrDeleter; friend class PhysicsPlayerController; friend class PhysicsBody; public: PhysicsCollisionShape(const PhysicsCollisionShape&) = delete; PhysicsCollisionShape& operator=(const PhysicsCollisionShape&) = delete; private: union { ClassWrapper m_shapeBase; ClassWrapper m_box; ClassWrapper m_sphere; ClassWrapper m_capsule; ClassWrapper m_convex; ClassWrapper m_mesh; ClassWrapper m_scaled; ///< We don't hold a reference to the target shape to avoid locking mutexes twice. }; PhysicsCollisionShape() : PhysicsObjectBase(PhysicsObjectType::kCollisionShape) { ANKI_ASSERT(&m_shapeBase == static_cast(&m_box)); ANKI_ASSERT(&m_shapeBase == static_cast(&m_sphere)); ANKI_ASSERT(&m_shapeBase == static_cast(&m_capsule)); ANKI_ASSERT(&m_shapeBase == static_cast(&m_scaled)); } ~PhysicsCollisionShape() { m_shapeBase.destroy(); } }; } // end namespace anki