Skip to content

Instantly share code, notes, and snippets.

@Zerophase
Last active August 29, 2015 14:16
Show Gist options
  • Save Zerophase/5266eeea9543deea8cf1 to your computer and use it in GitHub Desktop.
Save Zerophase/5266eeea9543deea8cf1 to your computer and use it in GitHub Desktop.
Collision Detection
public class AABB3D
{
private Vector3 center;
public Vector3 Center { get { return center; } set { center = value; } }
private float[] halfWidth;
public float HalfHeight
{
get { return halfWidth[1]; } set { halfWidth[1] = value; }
}
public float HalfWidth
{
get { return halfWidth[0]; } set { halfWidth[0] = value; }
}
public float HalfDepth
{
get { return halfWidth[2]; }
set { halfWidth[2] = value; }
}
public float[] HalfWidths
{
get { return halfWidth; }
set { halfWidth = value; }
}
public Vector3 Velocity = Vector3.zero;
public Vector3[] NormalCollision = new Vector3[3];
public AABB3D()
{
halfWidth = new float[3];
}
public AABB3D(Vector3 center, float width, float height, float depth)
{
this.center = center;
halfWidth = new float[3] {width/2.0f, height/2.0f, depth/ 2.0f};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment