Fixed incorrect edge preference for convex vs convex

This commit is contained in:
Diren D Bharwani 2023-03-02 05:23:08 +08:00
parent aebf1fc6ec
commit f4b7618fc2
5 changed files with 131 additions and 14 deletions

View File

@ -1,4 +1,4 @@
Start Maximized: true Start Maximized: true
Working Scene ID: 92914350 Working Scene ID: 92914350
Window Size: {x: 1920, y: 1080} Window Size: {x: 2000, y: 1518}
Style: 0 Style: 0

View File

@ -28,9 +28,9 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Camera Component: Camera Component:
Position: {x: 5, y: 5, z: 0} Position: {x: 0, y: 0, z: 7}
Pitch: 0 Pitch: 0
Yaw: 90 Yaw: 0
Roll: 0 Roll: 0
Width: 1920 Width: 1920
Height: 1080 Height: 1080
@ -45,7 +45,7 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 7.5, z: 0.75} Translate: {x: 0, y: 7.5, z: 0}
Rotate: {x: -0, y: 0, z: 0.785398185} Rotate: {x: -0, y: 0, z: 0.785398185}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 1, y: 1, z: 1}
IsActive: true IsActive: true
@ -55,7 +55,7 @@
Mass: 0.52359879 Mass: 0.52359879
Drag: 0.00999999978 Drag: 0.00999999978
Angular Drag: 0 Angular Drag: 0
Use Gravity: true Use Gravity: false
Gravity Scale: 1 Gravity Scale: 1
Interpolate: true Interpolate: true
Sleeping Enabled: true Sleeping Enabled: true
@ -176,3 +176,113 @@
Rotation Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 7
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 3}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Collider Component:
DrawColliders: false
Colliders:
- Is Trigger: false
Collision Tag: 1
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 8
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -1, y: 7, z: 0}
Rotate: {x: 0, y: 0, z: 0.785398185}
Scale: {x: 0.999999642, y: 0.999998569, z: 0.999999642}
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
DrawColliders: false
Colliders:
- Is Trigger: false
Collision Tag: 1
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts:
- Type: PhysicsTestObj
Enabled: true
forceAmount: 250
torqueAmount: 5
- EID: 65545
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2, y: 5, z: 3}
Rotate: {x: 0, y: 0, z: 0.785398185}
Scale: {x: 0.999999642, y: 0.999998569, z: 0.999999642}
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
DrawColliders: false
Colliders:
- Is Trigger: false
Collision Tag: 1
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~

View File

@ -4,7 +4,7 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Camera Component: Camera Component:
Position: {x: 0, y: 1, z: 3} Position: {x: 0, y: 1, z: 5}
Pitch: 0 Pitch: 0
Yaw: 0 Yaw: 0
Roll: 0 Roll: 0
@ -22,8 +22,8 @@
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 0, z: 0} Translate: {x: 0, y: 0, z: 0}
Rotate: {x: 0, y: 0, z: 0} Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 5, y: 0.999998808, z: 5}
IsActive: true IsActive: true
Collider Component: Collider Component:
DrawColliders: false DrawColliders: false
@ -45,7 +45,7 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 2, z: 0} Translate: {x: 1.5, y: 2, z: 1.5}
Rotate: {x: 0, y: 0.785398185, z: 0} Rotate: {x: 0, y: 0.785398185, z: 0}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 1, y: 1, z: 1}
IsActive: true IsActive: true
@ -79,4 +79,8 @@
Position Offset: {x: 0, y: 0, z: 0} Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: PhysicsTestObj
Enabled: true
forceAmount: 50
torqueAmount: 500

View File

@ -153,6 +153,7 @@ namespace SHADE
cachedInfo.info.refFace = minFaceQuery.closestFace; cachedInfo.info.refFace = minFaceQuery.closestFace;
} }
minFaceQuery.bestDistance = std::max(FACE_QUERY_A.bestDistance, FACE_QUERY_B.bestDistance);
// If an edge pair contains the closest distance,vwe ignore any face queries and find the closest points on // If an edge pair contains the closest distance,vwe ignore any face queries and find the closest points on
// each edge and use that as the contact point. // each edge and use that as the contact point.
@ -516,10 +517,10 @@ namespace SHADE
SHContact contact; SHContact contact;
contact.penetration = -DIST; contact.penetration = -DIST;
// A: Incident, B: Reference // A: Reference, B: Incident
// Project the clipped point onto the reference place for localPointB // Project the clipped point onto the reference place for localPointA
contact.localPointA = INV_TF_INC * (TF_REF * POS); contact.localPointA = POS + LOCAL_REF_NORMAL * SHVec3::Dot(LOCAL_REF_NORMAL, POS - LOCAL_REF_POINT);
contact.localPointB = POS + LOCAL_REF_NORMAL * SHVec3::Dot(LOCAL_REF_NORMAL, POS - LOCAL_REF_POINT); contact.localPointB = INV_TF_INC * (TF_REF * POS);
if (flip) if (flip)
{ {

View File

@ -247,6 +247,8 @@ namespace SHADE
void SHContactSolver::solve() noexcept void SHContactSolver::solve() noexcept
{ {
static const float TEMP_INF = std::numeric_limits<float>::infinity();
for (auto& [key, constraint] : contactConstraints) for (auto& [key, constraint] : contactConstraints)
{ {
SHVelocityState& velocityStateA = velocityStates.find(key.GetEntityA())->second; SHVelocityState& velocityStateA = velocityStates.find(key.GetEntityA())->second;