summaryrefslogtreecommitdiff
path: root/Runtime/Physics2D/PolygonColliderBase2D.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Physics2D/PolygonColliderBase2D.h
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/Physics2D/PolygonColliderBase2D.h')
-rw-r--r--Runtime/Physics2D/PolygonColliderBase2D.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/Runtime/Physics2D/PolygonColliderBase2D.h b/Runtime/Physics2D/PolygonColliderBase2D.h
new file mode 100644
index 0000000..02d7069
--- /dev/null
+++ b/Runtime/Physics2D/PolygonColliderBase2D.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#if ENABLE_2D_PHYSICS || DOXYGEN
+
+#include "Runtime/Math/Vector2.h"
+#include "Runtime/Utilities/dynamic_array.h"
+#include "Collider2D.h"
+#include "Runtime/Graphics/Polygon2D.h"
+
+class Vector3f;
+
+
+// --------------------------------------------------------------------------
+
+
+class PolygonColliderBase2D : public Collider2D
+{
+public:
+ REGISTER_DERIVED_ABSTRACT_CLASS (PolygonColliderBase2D, Collider2D)
+
+ PolygonColliderBase2D (MemLabelId label, ObjectCreationMode mode);
+
+ virtual const Polygon2D& GetPoly() const = 0;
+
+protected:
+ virtual void Create (const Rigidbody2D* ignoreRigidbody = NULL);
+
+ b2Shape* ExtractConvexShapes(dynamic_array<b2Shape*>& shapes, const Matrix4x4f& relativeTransform);
+ static int TransformPoints(const Polygon2D::TPath& path, const Matrix4x4f& relativeTransform, const Vector3f& scale, b2Vec2* outPoints);
+ static bool ValidatePolygonShape(const b2Vec2* const points, const int pointCount);
+};
+
+#endif