Jump to content
  • Advertisement

isu diss

Member
  • Content Count

    109
  • Joined

  • Last visited

Community Reputation

0 Neutral

1 Follower

About isu diss

  • Rank
    Member

Personal Information

  • Role
    Programmer
  • Interests
    Art
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Collision detection is based on the book, RTCD. It detects a collision when there's not. Any thoughts??? bool OBB_OBB_Intersection(OBB* A, OBB* B, float& s) { float ra, rb; XMMATRIX R, AbsR; // Compute rotation matrix expressing b in a’s coordinate frame for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) R.r[i].m128_f32[j] = XMVector3Dot(A->GetOrientation().r[i], B->GetOrientation().r[i]).m128_f32[0]; // Compute translation vector t XMVECTOR t = (XMLoadFloat3(&B->GetCenter()) - XMLoadFloat3(&A->GetCenter())); // Bring translation into a’s coordinate frame t = XMVectorSet(XMVector3Dot(t, A->GetOrientation().r[0]).m128_f32[0], XMVector3Dot(t, A->GetOrientation().r[1]).m128_f32[0], XMVector3Dot(t, A->GetOrientation().r[2]).m128_f32[0], 1.0f); // Compute common subexpressions. Add in an epsilon term to // counteract arithmetic errors when two edges are parallel and // their cross product is (near) null const float EPSILON = 1.0e-6f; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) AbsR.r[i].m128_f32[j] = abs(R.r[i].m128_f32[j]) + EPSILON; // Test axes L = A0, L = A1, L = A2 for (int i = 0; i < 3; i++) { ra = XMLoadFloat3(&A->GetExtents()).m128_f32[i]; rb = B->GetExtents().x * AbsR.r[i].m128_f32[0] + B->GetExtents().y * AbsR.r[i].m128_f32[1] + B->GetExtents().z * AbsR.r[i].m128_f32[2]; if (abs(t.m128_f32[i]) > ra + rb) return false; s = abs(t.m128_f32[i]) - (ra + rb); } // Test axes L = B0, L = B1, L = B2 for (int i = 0; i < 3; i++) { ra = A->GetExtents().x * AbsR.r[0].m128_f32[i] + A->GetExtents().y * AbsR.r[1].m128_f32[i] + A->GetExtents().z * AbsR.r[2].m128_f32[i]; rb = XMLoadFloat3(&B->GetExtents()).m128_f32[i]; if (abs(t.m128_f32[0] * R.r[0].m128_f32[i] + t.m128_f32[1] * R.r[1].m128_f32[i] + t.m128_f32[2] * R.r[2].m128_f32[i]) > ra + rb) return false; s = abs(t.m128_f32[0] * R.r[0].m128_f32[i] + t.m128_f32[1] * R.r[1].m128_f32[i] + t.m128_f32[2] * R.r[2].m128_f32[i]) - (ra + rb); } // Test axis L = A0 x B0 ra = A->GetExtents().y * AbsR.r[2].m128_f32[0] + A->GetExtents().z * AbsR.r[1].m128_f32[0]; rb = B->GetExtents().y * AbsR.r[0].m128_f32[2] + B->GetExtents().z * AbsR.r[0].m128_f32[1]; if (abs(t.m128_f32[2] * R.r[1].m128_f32[0] - t.m128_f32[1] * R.r[2].m128_f32[0]) > ra + rb) return false; s = abs(t.m128_f32[2] * R.r[1].m128_f32[0] - t.m128_f32[1] * R.r[2].m128_f32[0]) - (ra + rb); // Test axis L = A0 x B1 ra = A->GetExtents().y * AbsR.r[2].m128_f32[1] + A->GetExtents().z * AbsR.r[1].m128_f32[1]; rb = B->GetExtents().x * AbsR.r[0].m128_f32[2] + B->GetExtents().z * AbsR.r[0].m128_f32[0]; if (abs(t.m128_f32[2] * R.r[1].m128_f32[1] - t.m128_f32[1] * R.r[2].m128_f32[1]) > ra + rb) return false; s = abs(t.m128_f32[2] * R.r[1].m128_f32[1] - t.m128_f32[1] * R.r[2].m128_f32[1]) - (ra + rb); // Test axis L = A0 x B2 ra = A->GetExtents().y * AbsR.r[2].m128_f32[2] + A->GetExtents().z * AbsR.r[1].m128_f32[2]; rb = B->GetExtents().x * AbsR.r[0].m128_f32[1] + B->GetExtents().y * AbsR.r[0].m128_f32[0]; if (abs(t.m128_f32[2] * R.r[1].m128_f32[2] - t.m128_f32[1] * R.r[2].m128_f32[2]) > ra + rb) return false; s = abs(t.m128_f32[2] * R.r[1].m128_f32[2] - t.m128_f32[1] * R.r[2].m128_f32[2]) - (ra + rb); // Test axis L = A1 x B0 ra = A->GetExtents().x * AbsR.r[2].m128_f32[0] + A->GetExtents().z * AbsR.r[0].m128_f32[0]; rb = B->GetExtents().y * AbsR.r[1].m128_f32[2] + B->GetExtents().z * AbsR.r[1].m128_f32[1]; if (abs(t.m128_f32[0] * R.r[2].m128_f32[0] - t.m128_f32[2] * R.r[0].m128_f32[0]) > ra + rb) return false; s = abs(t.m128_f32[0] * R.r[2].m128_f32[0] - t.m128_f32[2] * R.r[0].m128_f32[0]) - (ra + rb); // Test axis L = A1 x B1 ra = A->GetExtents().x * AbsR.r[2].m128_f32[1] + A->GetExtents().z * AbsR.r[0].m128_f32[1]; rb = B->GetExtents().x * AbsR.r[1].m128_f32[2] + B->GetExtents().z * AbsR.r[1].m128_f32[0]; if (abs(t.m128_f32[0] * R.r[2].m128_f32[1] - t.m128_f32[2] * R.r[0].m128_f32[1]) > ra + rb) return false; s = abs(t.m128_f32[0] * R.r[2].m128_f32[1] - t.m128_f32[2] * R.r[0].m128_f32[1]) - (ra + rb); // Test axis L = A1 x B2 ra = A->GetExtents().x * AbsR.r[2].m128_f32[2] + A->GetExtents().z * AbsR.r[0].m128_f32[2]; rb = B->GetExtents().x * AbsR.r[1].m128_f32[1] + B->GetExtents().y * AbsR.r[1].m128_f32[0]; if (abs(t.m128_f32[0] * R.r[2].m128_f32[2] - t.m128_f32[2] * R.r[0].m128_f32[2]) > ra + rb) return false; s = abs(t.m128_f32[0] * R.r[2].m128_f32[2] - t.m128_f32[2] * R.r[0].m128_f32[2]) - (ra + rb); // Test axis L = A2 x B0 ra = A->GetExtents().x * AbsR.r[1].m128_f32[0] + A->GetExtents().y * AbsR.r[0].m128_f32[0]; rb = B->GetExtents().y * AbsR.r[2].m128_f32[2] + B->GetExtents().z * AbsR.r[2].m128_f32[1]; if (abs(t.m128_f32[1] * R.r[0].m128_f32[0] - t.m128_f32[0] * R.r[1].m128_f32[0]) > ra + rb) return false; s = abs(t.m128_f32[1] * R.r[0].m128_f32[0] - t.m128_f32[0] * R.r[1].m128_f32[0]) - (ra + rb); // Test axis L = A2 x B1 ra = A->GetExtents().x * AbsR.r[1].m128_f32[1] + A->GetExtents().y * AbsR.r[0].m128_f32[1]; rb = B->GetExtents().x * AbsR.r[2].m128_f32[2] + B->GetExtents().z * AbsR.r[2].m128_f32[0]; if (abs(t.m128_f32[1] * R.r[0].m128_f32[1] - t.m128_f32[0] * R.r[1].m128_f32[1]) > ra + rb) return false; s = abs(t.m128_f32[1] * R.r[0].m128_f32[1] - t.m128_f32[0] * R.r[1].m128_f32[1]) - (ra + rb); // Test axis L = A2 x B2 ra = A->GetExtents().x * AbsR.r[1].m128_f32[2] + A->GetExtents().y * AbsR.r[0].m128_f32[2]; rb = B->GetExtents().x * AbsR.r[2].m128_f32[1] + B->GetExtents().y * AbsR.r[2].m128_f32[0]; if (abs(t.m128_f32[1] * R.r[0].m128_f32[2] - t.m128_f32[0] * R.r[1].m128_f32[2]) > ra + rb) return false; s = abs(t.m128_f32[1] * R.r[0].m128_f32[2] - t.m128_f32[0] * R.r[1].m128_f32[2]) - (ra + rb); // Since no separating axis is found, the OBBs must be intersecting return true; } int main() { float sep; OBB objA(XMFLOAT3(0,10,10),XMFLOAT3(.5f,.5f,.5f), XMMatrixRotationY(0)), objB(XMFLOAT3(0,11.8f,10.0f),XMFLOAT3(.5f,.5f,.5f), XMMatrixRotationY(0)); if (OBB_OBB_Intersection(&objA, &objB, sep)) cout << "intersecting is found; a separation" << sep << endl; system("pause"); return 0; } OBB.cpp OBB.h
  2. isu diss

    How do I stop sinking and sliding objects?

    I think I found the problem. When I changed the order of adding objects(adding ball before ground) into the physics system, the ball too didn't get resolved. If I add the ground first then add other objects ball gets resolved, bails get resolved. As far as I understood, My broad phase is the culprit. How to make a good broad phase??? World.cpp World.h
  3. isu diss

    How do I stop sinking and sliding objects?

    Before I try what you said earlier, I decided to use my first AABB-AABB code for once. It is much promising than OBB-OBB code. AFAIK the ball deviates as expected due to friction still stumps' have got problem. Here's the video.
  4. isu diss

    How do I stop sinking and sliding objects?

    Thank you sir for your valuable suggestions. I used Randy's working qu3e's obb code. I tried to find the problem but I couldn't find any. This is what happens in the simulation - Here's the arbiter code. Arbiter.cpp Arbiter.h
  5. isu diss

    How do I stop sinking and sliding objects?

    I changed to OBB from AABB. Here's the latest arbiter.cpp/.h. @Irlan Robson Can you look at this code too pls? If I can create good contact points, this whole problem could be solved. The problem with AABB was contact generation; the ball behaved as expected but stumps did not, they started to slide down the ground. Arbiter.cpp Arbiter.h
  6. isu diss

    How do I stop sinking and sliding objects?

    Thank you sir @Irlan Robsonfor looking at my code. download the video and play if you don't mind.
  7. isu diss

    How do I stop sinking and sliding objects?

    I'm sorry for the videos. I'm sorry @Irlan Robson@Dirk Gregorius. Here's the latest video. Pls I'm just asking you to look at my code(below arbiter.cpp/h above world.cpp/h) and tell me what's wrong. As far as I know, friction is at work, since ball deviates. Arbiter.cpp Arbiter.h ALM 2019-09-14 08-41-01-80_x265.mp4
  8. isu diss

    How do I stop sinking and sliding objects?

    I changed from impulse engine to box2d lite. still I'm dealing with weird motions. Arbiter.cpp Arbiter.h World.cpp World.h
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!