first commit
This commit is contained in:
59
include/framework/shape/shape_convex.h
Normal file
59
include/framework/shape/shape_convex.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
|
||||
nEngine
|
||||
Emmanuel Julien 2000-2010
|
||||
All Rights Reserved
|
||||
|
||||
http://www.gamestart3d.com
|
||||
Please refer to the included license.txt for license informations.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NSHAPECONVEX__
|
||||
#define __NSHAPECONVEX__
|
||||
|
||||
|
||||
#include "shape/shape.h"
|
||||
#include "container/narray.h"
|
||||
|
||||
|
||||
/*!
|
||||
@short Convex shape class.
|
||||
@author Emmanuel Julien (ejulien@gsworks.fr)
|
||||
*/
|
||||
struct nConvexShape : public nShape
|
||||
{
|
||||
Vector4 center;
|
||||
nArray <Vector4> vtx;
|
||||
|
||||
virtual Vector4 &GetCenter() const
|
||||
{ return center; }
|
||||
virtual float GetSupportDistance(const Vector4 &d) const
|
||||
{
|
||||
if (!vtx.GetCount())
|
||||
return 0;
|
||||
|
||||
float d = vtx[0].Dot(d);
|
||||
for (uint n = 1; n < vtx.GetCount(); ++n)
|
||||
{
|
||||
float _d = vtx[n].Dot(d);
|
||||
if (_d > d)
|
||||
d = _d;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
nConvexShape(const Vector4 &c, const nArray <Vector4> &v)
|
||||
{
|
||||
center = c;
|
||||
vtx.Clone(v);
|
||||
}
|
||||
nConvexShape()
|
||||
{
|
||||
center.Set(0, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // __NSHAPECONVEX__
|
||||
Reference in New Issue
Block a user