From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Physics2D/PolygonColliderBase2D.h | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Runtime/Physics2D/PolygonColliderBase2D.h (limited to 'Runtime/Physics2D/PolygonColliderBase2D.h') 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& 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 -- cgit v1.1-26-g67d0