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/Dynamics/Cloth.h | 101 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Runtime/Dynamics/Cloth.h (limited to 'Runtime/Dynamics/Cloth.h') diff --git a/Runtime/Dynamics/Cloth.h b/Runtime/Dynamics/Cloth.h new file mode 100644 index 0000000..06341c8 --- /dev/null +++ b/Runtime/Dynamics/Cloth.h @@ -0,0 +1,101 @@ +#pragma once +#include "Configuration/UnityConfigure.h" + +#if ENABLE_CLOTH || DOXYGEN + +#include "DeformableMesh.h" + +class Collider; + +namespace Unity +{ + +struct ClothAttachment +{ + PPtr m_Collider; + bool m_TwoWayInteraction; + bool m_Tearable; + + DECLARE_SERIALIZE (ClothAttachment) + + ClothAttachment() : + m_TwoWayInteraction(false), + m_Tearable(false) + { } + +}; + +class InteractiveCloth : public Cloth +{ +public: + REGISTER_DERIVED_CLASS (InteractiveCloth, Cloth) + DECLARE_OBJECT_SERIALIZE (InteractiveCloth) + + InteractiveCloth (MemLabelId label, ObjectCreationMode mode); + + virtual void ProcessMeshForRenderer (); + + virtual void FixedUpdate (); + virtual void AwakeFromLoad(AwakeFromLoadMode mode); + virtual void Reset (); + + void AddForceAtPosition (const Vector3f& force, const Vector3f& position, float radius, int mode); + void AttachToCollider (Collider *collider, bool tearable, bool twoWayInteraction); + void DetachFromCollider (Collider *collider); + + PPtr GetMesh () { return m_Mesh; } + void SetMesh (PPtr value); + + float GetFriction () { return m_Friction; } + void SetFriction (float value); + + float GetDensity () { return m_Density; } + void SetDensity (float value); + + float GetPressure () { return m_Pressure; } + void SetPressure (float value); + + float GetCollisionResponse () { return m_CollisionResponse; } + void SetCollisionResponse (float value); + + float GetTearFactor () { return m_TearFactor; } + void SetTearFactor (float value); + + float GetAttachmentTearFactor () { return m_AttachmentTearFactor; } + void SetAttachmentTearFactor (float value); + + float GetAttachmentResponse () { return m_AttachmentResponse; } + void SetAttachmentResponse (float value); + + bool GetIsTeared () { return m_IsTeared; } + + virtual void AddToManager (); + virtual void RemoveFromManager (); + +protected: + + virtual void Create (); + virtual void PauseSimulation (); + virtual void ResumeSimulation (); + + void CheckTearing(); + + // configuration + float m_Friction; /// m_AttachedColliders; + + // state + bool m_IsTeared; + PPtr m_CachedMesh; + BehaviourListNode m_FixedUpdateNode; +}; + +} + +#endif // ENABLE_CLOTH -- cgit v1.1-26-g67d0