Skip to content

Commit

Permalink
[Editor][Core] Working on serialization for components (colliders and…
Browse files Browse the repository at this point in the history
… joints)
  • Loading branch information
fabsgc committed Nov 1, 2024
1 parent e47dfbb commit 295b10f
Show file tree
Hide file tree
Showing 27 changed files with 157 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCBoxCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,13 @@ namespace te
_parent->AddCollider(static_object_cast<CCollider>(GetHandle()));
}
}

void CBoxCollider::ExportComponent(nlohmann::json& coJsonDocument) const
{
CCollider::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCBoxCollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ namespace te
/** @copydoc BoxCollider::GetExtents */
Vector3 GetExtents() const { return _extents; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCCapsuleCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,13 @@ namespace te
_parent->AddCollider(static_object_cast<CCollider>(GetHandle()));
}
}

void CCapsuleCollider::ExportComponent(nlohmann::json& coJsonDocument) const
{
CCollider::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCCapsuleCollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ namespace te
/** @copydoc CapsuleCollider::GetHeight */
float GetHeight() const { return _height; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCConeCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,13 @@ namespace te
_parent->AddCollider(static_object_cast<CCollider>(GetHandle()));
}
}

void CConeCollider::ExportComponent(nlohmann::json& coJsonDocument) const
{
CCollider::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCConeCollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ namespace te
/** @copydoc CapsuleCollider::GetHeight */
float GetHeight() const { return _height; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCConeTwistJoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,13 @@ namespace te
if (_internal != nullptr)
std::static_pointer_cast<ConeTwistJoint>(_internal)->SetMaxMotorImpulse(motorImpulse);
}

void CConeTwistJoint::ExportComponent(nlohmann::json& coJsonDocument) const
{
CJoint::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCConeTwistJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ namespace te
/** @copydoc ConeTwistJoint::GetMaxMotorImpulse */
bool GetMaxMotorImpulse() const { return _motorImpulse; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCCylinderCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,13 @@ namespace te
_parent->AddCollider(static_object_cast<CCollider>(GetHandle()));
}
}

void CCylinderCollider::ExportComponent(nlohmann::json& coJsonDocument) const
{
CCollider::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCCylinderCollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ namespace te
/** @copydoc CylinderCollider::GetExtents */
Vector3 GetExtents() const { return _extents; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCD6Joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,13 @@ namespace te
if (_internal != nullptr)
std::static_pointer_cast<D6Joint>(_internal)->SetAngularDamping(angularDamping);
}

void CD6Joint::ExportComponent(nlohmann::json& coJsonDocument) const
{
CJoint::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCD6Joint.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ namespace te
/** @copydoc D6Joint::GetAngularDamping */
float GetAngularDamping() const { return _angularDamping; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCHeightFieldCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,13 @@ namespace te
_parent->AddCollider(static_object_cast<CCollider>(GetHandle()));
}
}

void CHeightFieldCollider::ExportComponent(nlohmann::json& coJsonDocument) const
{
CCollider::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCHeightFieldCollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ namespace te
/** @copydoc HeightFieldCollider::GetMaxHeight */
float GetMaxHeight() const { return _maxHeight; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCHingeJoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,13 @@ namespace te
if (_internal != nullptr)
std::static_pointer_cast<HingeJoint>(_internal)->SetMotorVelocity(motorVelocity);
}

void CHingeJoint::ExportComponent(nlohmann::json& coJsonDocument) const
{
CJoint::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCHingeJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ namespace te
/** @copydoc HingeJoint::GetMotorVelocity */
bool GetMotorVelocity() const { return _motorVelocity; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
2 changes: 1 addition & 1 deletion Source/Framework/Core/Components/TeCJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace te
Joint* GetInternal() const { return _internal.get(); }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;
virtual void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;
Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCMeshCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,13 @@ namespace te
_parent->AddCollider(static_object_cast<CCollider>(GetHandle()));
}
}

void CMeshCollider::ExportComponent(nlohmann::json& coJsonDocument) const
{
CCollider::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCMeshCollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ namespace te

PhysicsMeshType GetCollisionType() const { return _collisionType; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCPlaneCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,13 @@ namespace te
_parent->AddCollider(static_object_cast<CCollider>(GetHandle()));
}
}

void CPlaneCollider::ExportComponent(nlohmann::json& coJsonDocument) const
{
CCollider::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCPlaneCollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ namespace te
/** @copydoc PlaneCollider::GetNormal */
const Vector3& GetNormal() const { return _normal; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCSliderJoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,13 @@ namespace te
if (_internal != nullptr)
std::static_pointer_cast<SliderJoint>(_internal)->SetMaxAngMotorForce(maxAngMotorForce);
}

void CSliderJoint::ExportComponent(nlohmann::json& coJsonDocument) const
{
CJoint::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCSliderJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ namespace te
/** @copydoc GetMaxAngMotorForce */
float GetMaxAngMotorForce() const { return _maxAngMotorForce; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCSphereCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,13 @@ namespace te
_parent->AddCollider(static_object_cast<CCollider>(GetHandle()));
}
}

void CSphereCollider::ExportComponent(nlohmann::json& coJsonDocument) const
{
CCollider::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
5 changes: 3 additions & 2 deletions Source/Framework/Core/Components/TeCSphereCollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace te
class TE_CORE_EXPORT CSphereCollider : public CCollider
{
public:


/** Return Component type */
static UINT32 GetComponentType() { return TypeID_Core::TID_CSphereCollider; }

Expand All @@ -31,6 +29,9 @@ namespace te
/** @copydoc SphereCollider::GetRadius */
float GetRadius() const { return _radius; }

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down
9 changes: 9 additions & 0 deletions Source/Framework/Core/Components/TeCSphericalJoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@ namespace te
{
CJoint::OnEnabled();
}

void CSphericalJoint::ExportComponent(nlohmann::json& coJsonDocument) const
{
CJoint::ExportComponent(coJsonDocument);

coJsonDocument["type"] = GetComponentType();

// TODO serialization
}
}
3 changes: 3 additions & 0 deletions Source/Framework/Core/Components/TeCSphericalJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ namespace te
/** @copydoc Component::Clone */
bool Clone(const HComponent& c, const String& suffix = "") override;

public:
void ExportComponent(nlohmann::json& coJsonDocument) const override;

protected:
friend class SceneObject;

Expand Down

0 comments on commit 295b10f

Please sign in to comment.