diff options
| author | Bryan Galdrikian <[email protected]> | 2017-08-28 13:55:34 -0700 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-08-28 13:55:34 -0700 |
| commit | 1e887d827e65a084a0ad0ba933c61a8330aeee07 (patch) | |
| tree | 1e2aab418dadd37f5dc0aae4d8b00e81d909fd24 /sdk/extensions/physx/source/physics | |
| parent | Removing ArtistTools and CurveEditor projects (diff) | |
| download | blast-1e887d827e65a084a0ad0ba933c61a8330aeee07.tar.xz blast-1e887d827e65a084a0ad0ba933c61a8330aeee07.zip | |
Candidate 1.1 release.
* SampleAssetViewer now unconditionally loads the commandline-defined asset.
* Better error handling in AuthoringTool (stderr and user error handler).
* More consistent commandline switches in AuthoringTool and ApexImporter (--ll, --tx, --px flags).
* NvBlastExtAuthoring
** Mesh cleaner, tries to remove self intersections and open edges in the interior of a mesh.
** Ability to set interior material to existing (external) material, or a new material id.
** Material ID remapping API.
** Rotation of voronoi cells used for fracturing.
* Fixed smoothing groups in FBX exporter code.
* Impulse passing from parent to child chunks fixed.
* Reading unskinned fbx meshes correctly.
* Collision hull generation from fbx meshes fixed.
* Win32/64 PerfTest crash fix.
Diffstat (limited to 'sdk/extensions/physx/source/physics')
4 files changed, 30 insertions, 29 deletions
diff --git a/sdk/extensions/physx/source/physics/NvBlastExtImpactDamageManager.cpp b/sdk/extensions/physx/source/physics/NvBlastExtImpactDamageManager.cpp index fc1f514..b7831cb 100644 --- a/sdk/extensions/physx/source/physics/NvBlastExtImpactDamageManager.cpp +++ b/sdk/extensions/physx/source/physics/NvBlastExtImpactDamageManager.cpp @@ -334,16 +334,13 @@ void ExtImpactDamageManagerImpl::applyDamage() for (const ImpactDamageData& data : m_impactDamageBuffer) { - if (data.force.magnitudeSquared() > m_settings.impulseMinThreshold * m_settings.impulseMinThreshold) - { - PxTransform t(data.actor->getPhysXActor().getGlobalPose().getInverse()); - PxVec3 force = t.rotate(data.force); - PxVec3 position = t.transform(data.position); + PxTransform t(data.actor->getPhysXActor().getGlobalPose().getInverse()); + PxVec3 force = t.rotate(data.force); + PxVec3 position = t.transform(data.position); - if (!damageFn || !damageFn(damageFnData, data.actor, data.shape, position, force)) - { - damageActor(data.actor, data.shape, position, force); - } + if (!damageFn || !damageFn(damageFnData, data.actor, data.shape, position, force)) + { + damageActor(data.actor, data.shape, position, force); } } m_impactDamageBuffer.clear(); @@ -366,10 +363,7 @@ void ExtImpactDamageManagerImpl::damageActor(ExtPxActor* actor, PxShape* /*shape { ensureBuffersSize(actor); - const float f0 = m_settings.impulseMinThreshold; - const float f1 = m_settings.impulseMaxThreshold; - const float impulse01 = PxClamp<float>((force.magnitude() - f0) / PxMax<float>(f1 - f0, 1.0f), 0, 1); - const float damage = m_settings.damageMax * impulse01; + const float damage = m_settings.hardness > 0.f ? force.magnitude() / m_settings.hardness : 0.f; const void* material = actor->getTkActor().getFamily().getMaterial(); if (!material) @@ -377,15 +371,16 @@ void ExtImpactDamageManagerImpl::damageActor(ExtPxActor* actor, PxShape* /*shape return; } - const float normalizedDamage = reinterpret_cast<const NvBlastExtMaterial*>(material)->getNormalizedDamage(damage); - if (normalizedDamage == 0.f) + float normalizedDamage = reinterpret_cast<const NvBlastExtMaterial*>(material)->getNormalizedDamage(damage); + if (normalizedDamage == 0.f || normalizedDamage < m_settings.damageThresholdMin) { return; } + normalizedDamage = PxClamp<float>(normalizedDamage, 0, m_settings.damageThresholdMax); const PxVec3 normal = force.getNormalized(); - const float maxDistance = m_settings.damageRadiusMax * impulse01; - const float minDistance = maxDistance * PxClamp<float>(1 - m_settings.damageAttenuation, 0, 1); + const float minDistance = m_settings.damageRadiusMax * normalizedDamage; + const float maxDistance = minDistance * PxClamp<float>(m_settings.damageFalloffRadiusFactor, 1, 32); NvBlastProgramParams programParams; programParams.damageDescCount = 1; @@ -397,8 +392,8 @@ void ExtImpactDamageManagerImpl::damageActor(ExtPxActor* actor, PxShape* /*shape NvBlastExtShearDamageDesc desc[] = { { normalizedDamage, - { normal[0], normal[1], normal[2] }, // shear - { position[0], position[1], position[2] }, // position + { normal[0], normal[1], normal[2] }, + { position[0], position[1], position[2] }, minDistance, maxDistance } @@ -418,7 +413,7 @@ void ExtImpactDamageManagerImpl::damageActor(ExtPxActor* actor, PxShape* /*shape NvBlastExtRadialDamageDesc desc[] = { { normalizedDamage, - { position[0], position[1], position[2] }, // position + { position[0], position[1], position[2] }, minDistance, maxDistance } diff --git a/sdk/extensions/physx/source/physics/NvBlastExtPxActorImpl.cpp b/sdk/extensions/physx/source/physics/NvBlastExtPxActorImpl.cpp index c298e07..47463a4 100644 --- a/sdk/extensions/physx/source/physics/NvBlastExtPxActorImpl.cpp +++ b/sdk/extensions/physx/source/physics/NvBlastExtPxActorImpl.cpp @@ -161,8 +161,11 @@ ExtPxActorImpl::ExtPxActorImpl(ExtPxFamilyImpl* family, TkActor* tkActor, const // set initial velocities if (!(m_rigidDynamic->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC)) { - m_rigidDynamic->setLinearVelocity(pxActorInfo.m_linearVelocity); - m_rigidDynamic->setAngularVelocity(pxActorInfo.m_angularVelocity); + const PxVec3 COM = m_rigidDynamic->getGlobalPose().transform(m_rigidDynamic->getCMassLocalPose().p); + const PxVec3 linearVelocity = pxActorInfo.m_parentLinearVelocity + pxActorInfo.m_parentAngularVelocity.cross(COM - pxActorInfo.m_parentCOM); + const PxVec3 angularVelocity = pxActorInfo.m_parentAngularVelocity; + m_rigidDynamic->setLinearVelocity(linearVelocity); + m_rigidDynamic->setAngularVelocity(angularVelocity); } } diff --git a/sdk/extensions/physx/source/physics/NvBlastExtPxActorImpl.h b/sdk/extensions/physx/source/physics/NvBlastExtPxActorImpl.h index 5635591..db460e8 100644 --- a/sdk/extensions/physx/source/physics/NvBlastExtPxActorImpl.h +++ b/sdk/extensions/physx/source/physics/NvBlastExtPxActorImpl.h @@ -49,8 +49,9 @@ struct PxActorCreateInfo { PxTransform m_transform; PxVec3 m_scale; - PxVec3 m_linearVelocity; - PxVec3 m_angularVelocity; + PxVec3 m_parentLinearVelocity; + PxVec3 m_parentAngularVelocity; + PxVec3 m_parentCOM; }; diff --git a/sdk/extensions/physx/source/physics/NvBlastExtPxFamilyImpl.cpp b/sdk/extensions/physx/source/physics/NvBlastExtPxFamilyImpl.cpp index 530bbe3..09e26d4 100644 --- a/sdk/extensions/physx/source/physics/NvBlastExtPxFamilyImpl.cpp +++ b/sdk/extensions/physx/source/physics/NvBlastExtPxFamilyImpl.cpp @@ -118,8 +118,8 @@ bool ExtPxFamilyImpl::spawn(const physx::PxTransform& pose, const physx::PxVec3& for (uint32_t i = 0; i < actorCount; ++i) { PxActorCreateInfo& pxActorInfo = m_newActorCreateInfo[i]; - pxActorInfo.m_angularVelocity = PxVec3(PxZero); - pxActorInfo.m_linearVelocity = PxVec3(PxZero); + pxActorInfo.m_parentAngularVelocity = PxVec3(PxZero); + pxActorInfo.m_parentLinearVelocity = PxVec3(PxZero); pxActorInfo.m_transform = pose; pxActorInfo.m_scale = scale; } @@ -176,13 +176,15 @@ void ExtPxFamilyImpl::receive(const TkEvent* events, uint32_t eventCount) for (uint32_t j = totalNewActorsCount; j < totalNewActorsCount + newActorsCount; ++j) { - m_newActorCreateInfo[j].m_transform = parentPxActor ? parentPxActor->getGlobalPose() : m_initialTransform; + const PxTransform parentTransform = parentPxActor ? parentPxActor->getGlobalPose() : m_initialTransform; + m_newActorCreateInfo[j].m_transform = parentTransform; + m_newActorCreateInfo[j].m_parentCOM = parentTransform.transform(parentPxActor ? parentPxActor->getCMassLocalPose().p : PxVec3(PxZero)); //TODO: Get the current scale of the actor! m_newActorCreateInfo[j].m_scale = m_initialScale; - m_newActorCreateInfo[j].m_linearVelocity = parentPxActor ? parentPxActor->getLinearVelocity() : PxVec3(PxZero); - m_newActorCreateInfo[j].m_angularVelocity = parentPxActor ? parentPxActor->getAngularVelocity() : PxVec3(PxZero); + m_newActorCreateInfo[j].m_parentLinearVelocity = parentPxActor ? parentPxActor->getLinearVelocity() : PxVec3(PxZero); + m_newActorCreateInfo[j].m_parentAngularVelocity = parentPxActor ? parentPxActor->getAngularVelocity() : PxVec3(PxZero); m_newActorsBuffer[j] = splitEvent->children[j - totalNewActorsCount]; } |