Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added repulsion for sides of boat

  • Loading branch information...
commit aa9b9723a5fd5a0064a0beb6111df749620a7a76 1 parent efb0311
@gnuvince authored
Showing with 12 additions and 8 deletions.
  1. +12 −8 Application/Sources/Scene/CollisionHandler.cpp
View
20 Application/Sources/Scene/CollisionHandler.cpp
@@ -105,17 +105,21 @@ void CollisionHandler::ResolveCollision( Boat& boat, Buoy& buoy )
}
if (collision) {
- real delta = boat.GetSizeZ() / 2 + buoy.GetRadius();
+ real deltaZ = boat.GetSizeZ() / 2 + buoy.GetRadius();
+ real deltaX = boat.GetSizeX() / 2 + buoy.GetRadius();
buoy.OnCollide();
Vector3<real> v;
+
if (BitIsSet(tbrl, TOP))
- v = Vector3<real>(buoy_center.X(), buoy_center.Y(), -delta);
- else if (BitIsSet(tbrl, BOTTOM)) {
- v = Vector3<real>(buoy_center.X(), buoy_center.Y(), delta);
- }
- else {
- v = Vector3<real>(0, 0, -delta);
- }
+ v = Vector3<real>(buoy_center.X(), buoy_center.Y(), -deltaZ);
+ else if (BitIsSet(tbrl, BOTTOM))
+ v = Vector3<real>(buoy_center.X(), buoy_center.Y(), deltaZ);
+ else if (BitIsSet(tbrl, LEFT))
+ v = Vector3<real>(-deltaX, buoy_center.Y(), buoy_center.Z());
+ else if (BitIsSet(tbrl, RIGHT))
+ v = Vector3<real>(deltaX, buoy_center.Y(), buoy_center.Z());
+
+
Vector3<real> v2 = boat.GetLocalToGlobal() * v;
Vector3<real> v3 = buoy.GetGlobalToLocal() * v2;
Please sign in to comment.
Something went wrong with that request. Please try again.