Open ohmaya opened 10 months ago
Could you describe this issue in terms of observed vs expected behaviors as well as some context to help us understand the impact of this bug?
Basically, the difference:
Solution:
@ohmaya thank you for the feedback. You could explain in detail the behavior of your scene in the context of simulation and running in game mode.
The PhysX scene in the Editor is simpler to run in game mode (or game launcher). You can see a difference in those scenes with PhysX Nvidia Debugger. It is possible that the behavior for ClothComponent
and EditorClothComponent
is different because some PhysX primitives are not created or set up in the scene in Editor.
You can verify if there is no blocker for that from the simplification mentioned above. If true feel free to request such a feature.
Agreed in sig-simulation issue triage, I added triage/needs-information
label, and we are waiting for 7.12.2023.
If no further information is provided, I will close the issue.
already.. fixed & solution provided.. 3 weeks ago..
Great, thanks @ohmaya! Please provide a link to PR with the solution mentioned above, since I cannot find it.
@ohmaya it would be great to provide a PR to fix your issue since you stated that was fixed. I do not have much experience with NvCloth Gem, but we would be more than happy to review your contribution merge its development branch, and include it in the next releases. Here is a guide on contribution to O3DE: https://www.docs.o3de.org/docs/contributing/ .
Setting up contribution looks involving quite something to go through.
While implementing the feature is easy:
->Field("SimulateInEditor", &EditorClothComponent::m_simulateInEditor)
EditorActorComponent.h
void SetRayTracingEnabled(bool enabled) override;
// Added code start
size_t GetJointIndexByName(const char* name) const override;
AZ::Transform GetJointTransform(size_t jointIndex, Space space) const override;
Physics::AnimationConfiguration* GetPhysicsConfig() const override;
// Added code end
EditorActorComponent.cpp
// Added code start
size_t EditorActorComponent::GetJointIndexByName(const char* name) const
{
AZ_Assert(m_actorInstance, "The actor instance needs to be valid.");
Node* node = m_actorInstance->GetActor()->GetSkeleton()->FindNodeByNameNoCase(name);
if (node)
{
return static_cast<size_t>(node->GetNodeIndex());
}
return ActorComponentRequests::s_invalidJointIndex;
}
AZ::Transform EditorActorComponent::GetJointTransform(size_t jointIndex, Space space) const
{
AZ_Assert(m_actorInstance, "The actor instance needs to be valid.");
const size_t index = jointIndex;
const size_t numNodes = m_actorInstance->GetActor()->GetNumNodes();
AZ_Error("EMotionFX", index < numNodes, "GetJointTransform: The joint index %zu is out of bounds [0;%zu]. Entity: %s",
index, numNodes, GetEntity()->GetName().c_str());
if (index >= numNodes)
{
return AZ::Transform::CreateIdentity();
}
Pose* currentPose = m_actorInstance->GetTransformData()->GetCurrentPose();
switch (space)
{
case Space::LocalSpace:
{
return MCore::EmfxTransformToAzTransform(currentPose->GetLocalSpaceTransform(index));
}
case Space::ModelSpace:
{
return MCore::EmfxTransformToAzTransform(currentPose->GetModelSpaceTransform(index));
}
case Space::WorldSpace:
{
return MCore::EmfxTransformToAzTransform(currentPose->GetWorldSpaceTransform(index));
}
default:
AZ_Assert(false, "Unsupported space in GetJointTransform!");
}
return AZ::Transform::CreateIdentity();
}
Physics::AnimationConfiguration* EditorActorComponent::GetPhysicsConfig() const
{
if (m_actorInstance)
{
Actor* actor = m_actorInstance->GetActor();
const AZStd::shared_ptr<PhysicsSetup>& physicsSetup = actor->GetPhysicsSetup();
if (physicsSetup)
{
return &physicsSetup->GetConfig();
}
}
return nullptr;
}
// Added code end
void EditorActorComponent::UpdateRenderFlags()
EditorClothComponent.cpp
->Field("Configuration", &EditorClothComponent::m_config)
// Added code start
->Field("SimulateInEditor", &EditorClothComponent::m_simulateInEditor)
// Added code end
->Version(0)
Need to:
https://github.com/o3de/o3de/blob/development/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp#L188 // It will return a valid instance if it's an actor with cloth colliders in it. m_actorClothColliders = ActorClothColliders::Create(m_entityId);
https://github.com/o3de/o3de/blob/development/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ActorClothColliders.cpp#L64
While Run > Simulate does take colliders into consideration.
Thanks.