|
@@ -6,6 +6,7 @@
|
|
|
#pragma once
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <anki/physics/PhysicsObject.h>
|
|
#include <anki/physics/PhysicsObject.h>
|
|
|
|
|
+#include <anki/util/WeakArray.h>
|
|
|
|
|
|
|
|
namespace anki
|
|
namespace anki
|
|
|
{
|
|
{
|
|
@@ -13,21 +14,6 @@ namespace anki
|
|
|
/// @addtogroup physics
|
|
/// @addtogroup physics
|
|
|
/// @{
|
|
/// @{
|
|
|
|
|
|
|
|
-/// Standard initializer for all collision shapes.
|
|
|
|
|
-struct PhysicsCollisionShapeInitInfo
|
|
|
|
|
-{
|
|
|
|
|
- // Empty for now
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-/// Type of supported physics collision shapes.
|
|
|
|
|
-enum class PhysicsCollisionShapeType : U8
|
|
|
|
|
-{
|
|
|
|
|
- NONE,
|
|
|
|
|
- SPHERE,
|
|
|
|
|
- BOX,
|
|
|
|
|
- STATIC_TRIANGLE_SOUP
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
/// The base of all collision shapes.
|
|
/// The base of all collision shapes.
|
|
|
class PhysicsCollisionShape : public PhysicsObject
|
|
class PhysicsCollisionShape : public PhysicsObject
|
|
|
{
|
|
{
|
|
@@ -40,85 +26,47 @@ public:
|
|
|
~PhysicsCollisionShape();
|
|
~PhysicsCollisionShape();
|
|
|
|
|
|
|
|
anki_internal:
|
|
anki_internal:
|
|
|
- NewtonCollision* getNewtonShape() const
|
|
|
|
|
|
|
+ btCollisionShape* getBtShape() const
|
|
|
{
|
|
{
|
|
|
ANKI_ASSERT(m_shape);
|
|
ANKI_ASSERT(m_shape);
|
|
|
return m_shape;
|
|
return m_shape;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
protected:
|
|
|
- NewtonCollision* m_shape = nullptr;
|
|
|
|
|
- void* m_sceneCollisionProxy = nullptr;
|
|
|
|
|
- static I32 m_gid;
|
|
|
|
|
|
|
+ btCollisionShape* m_shape = nullptr;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/// Sphere collision shape.
|
|
/// Sphere collision shape.
|
|
|
class PhysicsSphere final : public PhysicsCollisionShape
|
|
class PhysicsSphere final : public PhysicsCollisionShape
|
|
|
{
|
|
{
|
|
|
public:
|
|
public:
|
|
|
- PhysicsSphere(PhysicsWorld* world)
|
|
|
|
|
- : PhysicsCollisionShape(world)
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ~PhysicsSphere()
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ANKI_USE_RESULT Error create(PhysicsCollisionShapeInitInfo& init, F32 radius);
|
|
|
|
|
|
|
+ PhysicsSphere(PhysicsWorld* world, F32 radius);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/// Box collision shape.
|
|
/// Box collision shape.
|
|
|
class PhysicsBox final : public PhysicsCollisionShape
|
|
class PhysicsBox final : public PhysicsCollisionShape
|
|
|
{
|
|
{
|
|
|
public:
|
|
public:
|
|
|
- PhysicsBox(PhysicsWorld* world)
|
|
|
|
|
- : PhysicsCollisionShape(world)
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ~PhysicsBox()
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ANKI_USE_RESULT Error create(PhysicsCollisionShapeInitInfo& init, const Vec3& extend);
|
|
|
|
|
|
|
+ PhysicsBox(PhysicsWorld* world, const Vec3& extend);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/// Convex hull collision shape.
|
|
/// Convex hull collision shape.
|
|
|
class PhysicsConvexHull final : public PhysicsCollisionShape
|
|
class PhysicsConvexHull final : public PhysicsCollisionShape
|
|
|
{
|
|
{
|
|
|
public:
|
|
public:
|
|
|
- PhysicsConvexHull(PhysicsWorld* world)
|
|
|
|
|
- : PhysicsCollisionShape(world)
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ~PhysicsConvexHull()
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ANKI_USE_RESULT Error create(
|
|
|
|
|
- PhysicsCollisionShapeInitInfo& init, const Vec3* positions, U32 positionsCount, U32 positionsStride);
|
|
|
|
|
|
|
+ PhysicsConvexHull(PhysicsWorld* world, const Vec3* positions, U32 positionsCount, U32 positionsStride);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/// Static triangle mesh shape.
|
|
/// Static triangle mesh shape.
|
|
|
class PhysicsTriangleSoup final : public PhysicsCollisionShape
|
|
class PhysicsTriangleSoup final : public PhysicsCollisionShape
|
|
|
{
|
|
{
|
|
|
public:
|
|
public:
|
|
|
- PhysicsTriangleSoup(PhysicsWorld* world)
|
|
|
|
|
- : PhysicsCollisionShape(world)
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ PhysicsTriangleSoup(PhysicsWorld* world, ConstWeakArray<Vec3> positions, ConstWeakArray<U32> indices);
|
|
|
|
|
|
|
|
- ~PhysicsTriangleSoup()
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ~PhysicsTriangleSoup();
|
|
|
|
|
|
|
|
- ANKI_USE_RESULT Error create(PhysicsCollisionShapeInitInfo& init,
|
|
|
|
|
- const Vec3* positions,
|
|
|
|
|
- U32 positionsStride,
|
|
|
|
|
- const U32* indices,
|
|
|
|
|
- U32 indicesCount);
|
|
|
|
|
|
|
+private:
|
|
|
|
|
+ btTriangleMesh* m_mesh = nullptr;
|
|
|
};
|
|
};
|
|
|
/// @}
|
|
/// @}
|
|
|
|
|
|