- * CollisionConstraint generates a collision vector
- * between two actors a and b, assuming they're rectangular
- * based on their size.
- */
-struct CollisionConstraint
-{
- /**
- * Collision Constraint constructor
- * The adjust (optional) parameter can be used to add a margin
- * to the actors. A +ve size will result in larger collisions,
- * while a -ve size will result in tighter collisions.
- *
- * @param[in] adjust (optional) Adjusts the rectangular size detection
- */
- CollisionConstraint(Vector3 adjust = Vector3::ZERO)
- : mAdjust(adjust)
- {
- }
-
- /**
- * Generates collision vector indicating whether Actor's A and B
- * have overlapped eachother, and the relative position of Actor B to A.
- *
- * @param[in] current The current collision-property (ignored)
- * @param[in] propertyA Actor A's Position property.
- * @param[in] propertyB Actor B's Position property.
- * @param[in] propertySizeA Actor A's Size property.
- * @param[in] propertySizeB Actor B's Size property.
- * @return The collision vector is returned.
- */
- Vector3 operator()(const Vector3& current,
- const PropertyInput& propertyA,
- const PropertyInput& propertyB,
- const PropertyInput& propertySizeA,
- const PropertyInput& propertySizeB)
- {
- const Vector3& a = propertyA.GetVector3();
- const Vector3& b = propertyB.GetVector3();
- const Vector3& sizeA = propertySizeA.GetVector3();
- const Vector3& sizeB = propertySizeB.GetVector3();
- const Vector3 sizeComb = (sizeA + sizeB + mAdjust) * 0.5f;
-
- // get collision relative to a.
- Vector3 delta = b - a;
-
- // Check if not overlapping Actors.
- if( (fabsf(delta.x) > sizeComb.width) ||
- (fabsf(delta.y) > sizeComb.height) )
- {
- delta = Vector3::ZERO; // not overlapping
- }
-
- return delta; // overlapping, return overlap vector relative to actor a.
- }
-
- const Vector3 mAdjust; ///< Size Adjustment value
-};
-
-/**