Upgrade Physics2D and Physics3D
This commit is contained in:
@@ -25,20 +25,20 @@ namespace Ndk
|
||||
friend class PhysicsSystem2D;
|
||||
|
||||
public:
|
||||
CollisionComponent2D(Nz::Collider2DRef geom = Nz::Collider2DRef());
|
||||
CollisionComponent2D(std::shared_ptr<Nz::Collider2D> geom = std::shared_ptr<Nz::Collider2D>());
|
||||
CollisionComponent2D(const CollisionComponent2D& collision);
|
||||
~CollisionComponent2D() = default;
|
||||
|
||||
Nz::Rectf GetAABB() const;
|
||||
const Nz::Collider2DRef& GetGeom() const;
|
||||
const std::shared_ptr<Nz::Collider2D>& GetGeom() const;
|
||||
const Nz::Vector2f& GetGeomOffset() const;
|
||||
|
||||
void Recenter(const Nz::Vector2f& origin);
|
||||
|
||||
void SetGeom(Nz::Collider2DRef geom, bool recomputeMoment = true, bool recomputeMassCenter = true);
|
||||
void SetGeom(std::shared_ptr<Nz::Collider2D> geom, bool recomputeMoment = true, bool recomputeMassCenter = true);
|
||||
void SetGeomOffset(const Nz::Vector2f& geomOffset);
|
||||
|
||||
CollisionComponent2D& operator=(Nz::Collider2DRef geom);
|
||||
CollisionComponent2D& operator=(std::shared_ptr<Nz::Collider2D> geom);
|
||||
CollisionComponent2D& operator=(CollisionComponent2D&& collision) = delete;
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
@@ -56,7 +56,7 @@ namespace Ndk
|
||||
void OnDetached() override;
|
||||
|
||||
std::unique_ptr<Nz::RigidBody2D> m_staticBody;
|
||||
Nz::Collider2DRef m_geom;
|
||||
std::shared_ptr<Nz::Collider2D> m_geom;
|
||||
bool m_bodyUpdated;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Ndk
|
||||
* \param geom Reference to a geometry symbolizing the entity
|
||||
*/
|
||||
|
||||
inline CollisionComponent2D::CollisionComponent2D(Nz::Collider2DRef geom) :
|
||||
inline CollisionComponent2D::CollisionComponent2D(std::shared_ptr<Nz::Collider2D> geom) :
|
||||
m_geom(std::move(geom)),
|
||||
m_bodyUpdated(false)
|
||||
{
|
||||
@@ -33,7 +33,7 @@ namespace Ndk
|
||||
* \return A constant reference to the physics geometry
|
||||
*/
|
||||
|
||||
inline const Nz::Collider2DRef& CollisionComponent2D::GetGeom() const
|
||||
inline const std::shared_ptr<Nz::Collider2D>& CollisionComponent2D::GetGeom() const
|
||||
{
|
||||
return m_geom;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace Ndk
|
||||
* \param geom Reference to a geometry symbolizing the entity
|
||||
*/
|
||||
|
||||
inline CollisionComponent2D& CollisionComponent2D::operator=(Nz::Collider2DRef geom)
|
||||
inline CollisionComponent2D& CollisionComponent2D::operator=(std::shared_ptr<Nz::Collider2D> geom)
|
||||
{
|
||||
SetGeom(geom);
|
||||
|
||||
|
||||
@@ -23,15 +23,15 @@ namespace Ndk
|
||||
friend class PhysicsSystem3D;
|
||||
|
||||
public:
|
||||
CollisionComponent3D(Nz::Collider3DRef geom = Nz::Collider3DRef());
|
||||
CollisionComponent3D(std::shared_ptr<Nz::Collider3D> geom = std::shared_ptr<Nz::Collider3D>());
|
||||
CollisionComponent3D(const CollisionComponent3D& collision);
|
||||
~CollisionComponent3D() = default;
|
||||
|
||||
const Nz::Collider3DRef& GetGeom() const;
|
||||
const std::shared_ptr<Nz::Collider3D>& GetGeom() const;
|
||||
|
||||
void SetGeom(Nz::Collider3DRef geom);
|
||||
void SetGeom(std::shared_ptr<Nz::Collider3D> geom);
|
||||
|
||||
CollisionComponent3D& operator=(Nz::Collider3DRef geom);
|
||||
CollisionComponent3D& operator=(std::shared_ptr<Nz::Collider3D> geom);
|
||||
CollisionComponent3D& operator=(CollisionComponent3D&& collision) = delete;
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
@@ -48,7 +48,7 @@ namespace Ndk
|
||||
void OnEntityEnabled() override;
|
||||
|
||||
std::unique_ptr<Nz::RigidBody3D> m_staticBody;
|
||||
Nz::Collider3DRef m_geom;
|
||||
std::shared_ptr<Nz::Collider3D> m_geom;
|
||||
bool m_bodyUpdated;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Ndk
|
||||
* \param geom Reference to a geometry symbolizing the entity
|
||||
*/
|
||||
|
||||
inline CollisionComponent3D::CollisionComponent3D(Nz::Collider3DRef geom) :
|
||||
inline CollisionComponent3D::CollisionComponent3D(std::shared_ptr<Nz::Collider3D> geom) :
|
||||
m_geom(std::move(geom)),
|
||||
m_bodyUpdated(false)
|
||||
{
|
||||
@@ -33,7 +33,7 @@ namespace Ndk
|
||||
* \return A constant reference to the physics geometry
|
||||
*/
|
||||
|
||||
inline const Nz::Collider3DRef& CollisionComponent3D::GetGeom() const
|
||||
inline const std::shared_ptr<Nz::Collider3D>& CollisionComponent3D::GetGeom() const
|
||||
{
|
||||
return m_geom;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace Ndk
|
||||
* \param geom Reference to a geometry symbolizing the entity
|
||||
*/
|
||||
|
||||
inline CollisionComponent3D& CollisionComponent3D::operator=(Nz::Collider3DRef geom)
|
||||
inline CollisionComponent3D& CollisionComponent3D::operator=(std::shared_ptr<Nz::Collider3D> geom)
|
||||
{
|
||||
SetGeom(geom);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user