Various tweaks
This commit is contained in:
@@ -58,9 +58,7 @@ API_STRUCT(NoDefault) struct FLAXENGINE_API Collision
|
||||
/// <summary>
|
||||
/// The total impulse applied to this contact pair to resolve the collision.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The total impulse is obtained by summing up impulses applied at all contact points in this collision pair.
|
||||
/// </remarks>
|
||||
/// <remarks>The total impulse is obtained by summing up impulses applied at all contact points in this collision pair.</remarks>
|
||||
API_FIELD() Vector3 Impulse;
|
||||
|
||||
/// <summary>
|
||||
@@ -87,9 +85,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the relative linear velocity of the two colliding objects.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Can be used to detect stronger collisions.
|
||||
/// </remarks>
|
||||
/// <remarks>Can be used to detect stronger collisions. </remarks>
|
||||
Vector3 GetRelativeVelocity() const
|
||||
{
|
||||
return ThisVelocity - OtherVelocity;
|
||||
|
||||
@@ -228,9 +228,7 @@ class QueryFilterPhysX : public PxQueryFilterCallback
|
||||
// Check mask
|
||||
const PxFilterData shapeFilter = shape->getQueryFilterData();
|
||||
if ((filterData.word0 & shapeFilter.word0) == 0)
|
||||
{
|
||||
return PxQueryHitType::eNONE;
|
||||
}
|
||||
|
||||
// Check if skip triggers
|
||||
const bool hitTriggers = filterData.word2 != 0;
|
||||
@@ -483,8 +481,10 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
#define PxHitFlagEmpty (PxHitFlags)0
|
||||
#define SCENE_QUERY_FLAGS (PxHitFlag::ePOSITION | PxHitFlag::eNORMAL | PxHitFlag::eFACE_INDEX | PxHitFlag::eUV)
|
||||
|
||||
#define SCENE_QUERY_SETUP(blockSingle) auto scenePhysX = (ScenePhysX*)scene; if (scene == nullptr) return false; \
|
||||
const PxHitFlags hitFlags = PxHitFlag::ePOSITION | PxHitFlag::eNORMAL | PxHitFlag::eUV; \
|
||||
PxQueryFilterData filterData; \
|
||||
filterData.flags |= PxQueryFlag::ePREFILTER; \
|
||||
filterData.data.word0 = layerMask; \
|
||||
@@ -1735,8 +1735,6 @@ void PhysicsBackend::EndSimulateScene(void* scene)
|
||||
|
||||
{
|
||||
PROFILE_CPU_NAMED("Physics.SendEvents");
|
||||
|
||||
scenePhysX->EventsCallback.CollectResults();
|
||||
scenePhysX->EventsCallback.SendTriggerEvents();
|
||||
scenePhysX->EventsCallback.SendCollisionEvents();
|
||||
scenePhysX->EventsCallback.SendJointEvents();
|
||||
@@ -1880,14 +1878,14 @@ bool PhysicsBackend::RayCast(void* scene, const Vector3& origin, const Vector3&
|
||||
{
|
||||
SCENE_QUERY_SETUP(true);
|
||||
PxRaycastBuffer buffer;
|
||||
return scenePhysX->Scene->raycast(C2P(origin - scenePhysX->Origin), C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter);
|
||||
return scenePhysX->Scene->raycast(C2P(origin - scenePhysX->Origin), C2P(direction), maxDistance, buffer, PxHitFlagEmpty, filterData, &QueryFilter);
|
||||
}
|
||||
|
||||
bool PhysicsBackend::RayCast(void* scene, const Vector3& origin, const Vector3& direction, RayCastHit& hitInfo, const float maxDistance, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
SCENE_QUERY_SETUP(true);
|
||||
PxRaycastBuffer buffer;
|
||||
if (!scenePhysX->Scene->raycast(C2P(origin - scenePhysX->Origin), C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->raycast(C2P(origin - scenePhysX->Origin), C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_SINGLE();
|
||||
return true;
|
||||
@@ -1897,7 +1895,7 @@ bool PhysicsBackend::RayCastAll(void* scene, const Vector3& origin, const Vector
|
||||
{
|
||||
SCENE_QUERY_SETUP(false);
|
||||
DynamicHitBuffer<PxRaycastHit> buffer;
|
||||
if (!scenePhysX->Scene->raycast(C2P(origin - scenePhysX->Origin), C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->raycast(C2P(origin - scenePhysX->Origin), C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_ALL();
|
||||
return true;
|
||||
@@ -1908,7 +1906,7 @@ bool PhysicsBackend::BoxCast(void* scene, const Vector3& center, const Vector3&
|
||||
SCENE_QUERY_SETUP_SWEEP_1();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxBoxGeometry geometry(C2P(halfExtents));
|
||||
return scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter);
|
||||
return scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, PxHitFlagEmpty, filterData, &QueryFilter);
|
||||
}
|
||||
|
||||
bool PhysicsBackend::BoxCast(void* scene, const Vector3& center, const Vector3& halfExtents, const Vector3& direction, RayCastHit& hitInfo, const Quaternion& rotation, const float maxDistance, uint32 layerMask, bool hitTriggers)
|
||||
@@ -1916,7 +1914,7 @@ bool PhysicsBackend::BoxCast(void* scene, const Vector3& center, const Vector3&
|
||||
SCENE_QUERY_SETUP_SWEEP_1();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxBoxGeometry geometry(C2P(halfExtents));
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_SINGLE();
|
||||
return true;
|
||||
@@ -1927,7 +1925,7 @@ bool PhysicsBackend::BoxCastAll(void* scene, const Vector3& center, const Vector
|
||||
SCENE_QUERY_SETUP_SWEEP();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxBoxGeometry geometry(C2P(halfExtents));
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_ALL();
|
||||
return true;
|
||||
@@ -1938,7 +1936,7 @@ bool PhysicsBackend::SphereCast(void* scene, const Vector3& center, const float
|
||||
SCENE_QUERY_SETUP_SWEEP_1();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin));
|
||||
const PxSphereGeometry geometry(radius);
|
||||
return scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter);
|
||||
return scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, PxHitFlagEmpty, filterData, &QueryFilter);
|
||||
}
|
||||
|
||||
bool PhysicsBackend::SphereCast(void* scene, const Vector3& center, const float radius, const Vector3& direction, RayCastHit& hitInfo, const float maxDistance, uint32 layerMask, bool hitTriggers)
|
||||
@@ -1946,7 +1944,7 @@ bool PhysicsBackend::SphereCast(void* scene, const Vector3& center, const float
|
||||
SCENE_QUERY_SETUP_SWEEP_1();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin));
|
||||
const PxSphereGeometry geometry(radius);
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_SINGLE();
|
||||
return true;
|
||||
@@ -1957,7 +1955,7 @@ bool PhysicsBackend::SphereCastAll(void* scene, const Vector3& center, const flo
|
||||
SCENE_QUERY_SETUP_SWEEP();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin));
|
||||
const PxSphereGeometry geometry(radius);
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_ALL();
|
||||
return true;
|
||||
@@ -1968,7 +1966,7 @@ bool PhysicsBackend::CapsuleCast(void* scene, const Vector3& center, const float
|
||||
SCENE_QUERY_SETUP_SWEEP_1();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxCapsuleGeometry geometry(radius, height * 0.5f);
|
||||
return scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter);
|
||||
return scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, PxHitFlagEmpty, filterData, &QueryFilter);
|
||||
}
|
||||
|
||||
bool PhysicsBackend::CapsuleCast(void* scene, const Vector3& center, const float radius, const float height, const Vector3& direction, RayCastHit& hitInfo, const Quaternion& rotation, const float maxDistance, uint32 layerMask, bool hitTriggers)
|
||||
@@ -1976,7 +1974,7 @@ bool PhysicsBackend::CapsuleCast(void* scene, const Vector3& center, const float
|
||||
SCENE_QUERY_SETUP_SWEEP_1();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxCapsuleGeometry geometry(radius, height * 0.5f);
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_SINGLE();
|
||||
return true;
|
||||
@@ -1987,7 +1985,7 @@ bool PhysicsBackend::CapsuleCastAll(void* scene, const Vector3& center, const fl
|
||||
SCENE_QUERY_SETUP_SWEEP();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxCapsuleGeometry geometry(radius, height * 0.5f);
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_ALL();
|
||||
return true;
|
||||
@@ -1999,7 +1997,7 @@ bool PhysicsBackend::ConvexCast(void* scene, const Vector3& center, const Collis
|
||||
SCENE_QUERY_SETUP_SWEEP_1();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxConvexMeshGeometry geometry((PxConvexMesh*)convexMesh->GetConvex(), PxMeshScale(C2P(scale)));
|
||||
return scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter);
|
||||
return scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, PxHitFlagEmpty, filterData, &QueryFilter);
|
||||
}
|
||||
|
||||
bool PhysicsBackend::ConvexCast(void* scene, const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, const Vector3& direction, RayCastHit& hitInfo, const Quaternion& rotation, const float maxDistance, uint32 layerMask, bool hitTriggers)
|
||||
@@ -2008,7 +2006,7 @@ bool PhysicsBackend::ConvexCast(void* scene, const Vector3& center, const Collis
|
||||
SCENE_QUERY_SETUP_SWEEP_1();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxConvexMeshGeometry geometry((PxConvexMesh*)convexMesh->GetConvex(), PxMeshScale(C2P(scale)));
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_SINGLE();
|
||||
return true;
|
||||
@@ -2020,7 +2018,7 @@ bool PhysicsBackend::ConvexCastAll(void* scene, const Vector3& center, const Col
|
||||
SCENE_QUERY_SETUP_SWEEP();
|
||||
const PxTransform pose(C2P(center - scenePhysX->Origin), C2P(rotation));
|
||||
const PxConvexMeshGeometry geometry((PxConvexMesh*)convexMesh->GetConvex(), PxMeshScale(C2P(scale)));
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, hitFlags, filterData, &QueryFilter))
|
||||
if (!scenePhysX->Scene->sweep(geometry, pose, C2P(direction), maxDistance, buffer, SCENE_QUERY_FLAGS, filterData, &QueryFilter))
|
||||
return false;
|
||||
SCENE_QUERY_COLLECT_ALL();
|
||||
return true;
|
||||
@@ -2608,9 +2606,8 @@ bool PhysicsBackend::RayCastShape(void* shape, const Vector3& position, const Qu
|
||||
auto shapePhysX = (PxShape*)shape;
|
||||
const Vector3 sceneOrigin = SceneOrigins[shapePhysX->getActor() ? shapePhysX->getActor()->getScene() : nullptr];
|
||||
const PxTransform trans(C2P(position - sceneOrigin), C2P(orientation));
|
||||
const PxHitFlags hitFlags = (PxHitFlags)0;
|
||||
PxRaycastHit hit;
|
||||
if (PxGeometryQuery::raycast(C2P(origin - sceneOrigin), C2P(direction), shapePhysX->getGeometry(), trans, maxDistance, hitFlags, 1, &hit) != 0)
|
||||
if (PxGeometryQuery::raycast(C2P(origin - sceneOrigin), C2P(direction), shapePhysX->getGeometry(), trans, maxDistance, PxHitFlagEmpty, 1, &hit) != 0)
|
||||
{
|
||||
resultHitDistance = hit.distance;
|
||||
return true;
|
||||
@@ -2623,9 +2620,8 @@ bool PhysicsBackend::RayCastShape(void* shape, const Vector3& position, const Qu
|
||||
auto shapePhysX = (PxShape*)shape;
|
||||
const Vector3 sceneOrigin = SceneOrigins[shapePhysX->getActor() ? shapePhysX->getActor()->getScene() : nullptr];
|
||||
const PxTransform trans(C2P(position - sceneOrigin), C2P(orientation));
|
||||
const PxHitFlags hitFlags = PxHitFlag::ePOSITION | PxHitFlag::eNORMAL | PxHitFlag::eFACE_INDEX | PxHitFlag::eUV;
|
||||
PxRaycastHit hit;
|
||||
if (PxGeometryQuery::raycast(C2P(origin - sceneOrigin), C2P(direction), shapePhysX->getGeometry(), trans, maxDistance, hitFlags, 1, &hit) == 0)
|
||||
if (PxGeometryQuery::raycast(C2P(origin - sceneOrigin), C2P(direction), shapePhysX->getGeometry(), trans, maxDistance, SCENE_QUERY_FLAGS, 1, &hit) == 0)
|
||||
return false;
|
||||
P2C(hit, hitInfo);
|
||||
hitInfo.Point += sceneOrigin;
|
||||
|
||||
@@ -38,10 +38,6 @@ void SimulationEventCallback::Clear()
|
||||
BrokenJoints.Clear();
|
||||
}
|
||||
|
||||
void SimulationEventCallback::CollectResults()
|
||||
{
|
||||
}
|
||||
|
||||
void SimulationEventCallback::SendCollisionEvents()
|
||||
{
|
||||
for (auto& c : RemovedCollisions)
|
||||
@@ -132,7 +128,6 @@ void SimulationEventCallback::onContact(const PxContactPairHeader& pairHeader, c
|
||||
//const PxU32 flippedContacts = (pair.flags & PxContactPairFlag::eINTERNAL_CONTACTS_ARE_FLIPPED);
|
||||
const bool hasImpulses = pair.flags.isSet(PxContactPairFlag::eINTERNAL_HAS_IMPULSES);
|
||||
const bool hasPostVelocities = !pair.flags.isSet(PxContactPairFlag::eACTOR_PAIR_LOST_TOUCH);
|
||||
PxU32 nbContacts = 0;
|
||||
PxVec3 totalImpulse(0.0f);
|
||||
|
||||
c.ThisActor = static_cast<PhysicsColliderActor*>(pair.shapes[0]->userData);
|
||||
@@ -144,29 +139,25 @@ void SimulationEventCallback::onContact(const PxContactPairHeader& pairHeader, c
|
||||
}
|
||||
|
||||
// Extract contact points
|
||||
c.ContactsCount = 0;
|
||||
while (i.hasNextPatch())
|
||||
{
|
||||
i.nextPatch();
|
||||
while (i.hasNextContact() && nbContacts < COLLISION_NAX_CONTACT_POINTS)
|
||||
while (i.hasNextContact() && c.ContactsCount < COLLISION_NAX_CONTACT_POINTS)
|
||||
{
|
||||
i.nextContact();
|
||||
|
||||
const PxVec3 point = i.getContactPoint();
|
||||
const PxVec3 normal = i.getContactNormal();
|
||||
if (hasImpulses)
|
||||
totalImpulse += normal * impulses[nbContacts];
|
||||
totalImpulse += normal * impulses[c.ContactsCount];
|
||||
|
||||
//PxU32 internalFaceIndex0 = flippedContacts ? iter.getFaceIndex1() : iter.getFaceIndex0();
|
||||
//PxU32 internalFaceIndex1 = flippedContacts ? iter.getFaceIndex0() : iter.getFaceIndex1();
|
||||
|
||||
ContactPoint& contact = c.Contacts[nbContacts];
|
||||
ContactPoint& contact = c.Contacts[c.ContactsCount++];
|
||||
contact.Point = P2C(point);
|
||||
contact.Normal = P2C(normal);
|
||||
contact.Separation = i.getSeparation();
|
||||
|
||||
nbContacts++;
|
||||
}
|
||||
}
|
||||
c.Impulse = P2C(totalImpulse);
|
||||
|
||||
// Extract velocities
|
||||
c.ThisVelocity = c.OtherVelocity = Vector3::Zero;
|
||||
@@ -183,9 +174,6 @@ void SimulationEventCallback::onContact(const PxContactPairHeader& pairHeader, c
|
||||
}
|
||||
}
|
||||
|
||||
c.ContactsCount = nbContacts;
|
||||
c.Impulse = P2C(totalImpulse);
|
||||
|
||||
if (pair.flags & PxContactPairFlag::eACTOR_PAIR_HAS_FIRST_TOUCH)
|
||||
{
|
||||
NewCollisions.Add(c);
|
||||
|
||||
@@ -49,11 +49,6 @@ public:
|
||||
/// </summary>
|
||||
void Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Generates the new/old/removed collisions and a valid trigger pairs.
|
||||
/// </summary>
|
||||
void CollectResults();
|
||||
|
||||
/// <summary>
|
||||
/// Sends the collision events to the managed objects.
|
||||
/// </summary>
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
/// <summary>
|
||||
/// Physical materials are used to define the response of a physical object when interacting dynamically with the world.
|
||||
/// </summary>
|
||||
API_CLASS(Attributes = "ContentContextMenu(\"New/Physics/Physical Material\")") class FLAXENGINE_API PhysicalMaterial final : public ISerializable
|
||||
API_CLASS(Attributes = "ContentContextMenu(\"New/Physics/Physical Material\")")
|
||||
class FLAXENGINE_API PhysicalMaterial final : public ISerializable
|
||||
{
|
||||
API_AUTO_SERIALIZATION();
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(PhysicalMaterial);
|
||||
|
||||
@@ -151,17 +151,17 @@ API_STRUCT() struct RayCastHit
|
||||
/// </summary>
|
||||
API_FIELD() float Distance;
|
||||
|
||||
/// <summary>
|
||||
/// The point in the world space where ray hit the collider.
|
||||
/// </summary>
|
||||
API_FIELD() Vector3 Point;
|
||||
|
||||
/// <summary>
|
||||
/// The index of the face that was hit. Valid only for convex mesh (polygon index), triangle mesh (triangle index) and height field (triangle index).
|
||||
/// </summary>
|
||||
/// <seealso cref="CollisionData.GetModelTriangle" />
|
||||
API_FIELD() uint32 FaceIndex;
|
||||
|
||||
/// <summary>
|
||||
/// The point in the world space where ray hit the collider.
|
||||
/// </summary>
|
||||
API_FIELD() Vector3 Point;
|
||||
|
||||
/// <summary>
|
||||
/// The barycentric coordinates of hit triangle. Valid only for triangle mesh and height field.
|
||||
/// </summary>
|
||||
|
||||
@@ -1431,7 +1431,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
|
||||
Transform srcNode = data.Skeleton.Nodes[nodeIndex].LocalTransform;
|
||||
auto& node = data.Skeleton.Nodes[nodeIndex];
|
||||
if (auto* channel = animation.GetChannel(node.Name))
|
||||
channel->Evaluate(frame, &srcNode, false);
|
||||
channel->Evaluate((float)frame, &srcNode, false);
|
||||
pose.Nodes[nodeIndex] = srcNode;
|
||||
}
|
||||
|
||||
@@ -1439,7 +1439,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
|
||||
key = Float3::Zero;
|
||||
for (int32 nodeIndex = 0; nodeIndex < nodes; nodeIndex++)
|
||||
key += pose.GetNodeModelTransformation(data.Skeleton, nodeIndex).Translation;
|
||||
key /= nodes;
|
||||
key /= (float)nodes;
|
||||
}
|
||||
|
||||
// Calculate skeleton center of mass movement over the animation frames
|
||||
@@ -1448,7 +1448,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
|
||||
for (int32 frame = 0; frame < frames; frame++)
|
||||
{
|
||||
auto& key = rootChannel.Position[frame];
|
||||
key.Time = frame;
|
||||
key.Time = (float)frame;
|
||||
key.Value = centerOfMass[frame] - centerOfMassRefPose;
|
||||
}
|
||||
|
||||
@@ -1494,7 +1494,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
|
||||
Transform srcNode = data.Skeleton.Nodes[nodeIndex].LocalTransform;
|
||||
auto& node = data.Skeleton.Nodes[nodeIndex];
|
||||
if (auto* channel = animation.GetChannel(node.Name))
|
||||
channel->Evaluate(frame, &srcNode, false);
|
||||
channel->Evaluate((float)frame, &srcNode, false);
|
||||
pose.Nodes[nodeIndex] = srcNode;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user