Skip to content
Snippets Groups Projects
Commit 95a1bd58 authored by Tazpn's avatar Tazpn
Browse files

More Collision helper methods

parent 302bb8d1
No related branches found
No related tags found
No related merge requests found
...@@ -72,6 +72,30 @@ public: ...@@ -72,6 +72,30 @@ public:
*/ */
NIFLIB_API vector<Vector3> GetNormals() const; NIFLIB_API vector<Vector3> GetNormals() const;
/*!
* Used to retrieve the distance to center for vertices. The size of the vector will either be zero if no normals are used, or be the same as the vertex count retrieved with the IShapeData::GetVertexCount function.
* \return A vector containing the normals used by this mesh, if any.
*/
NIFLIB_API vector<float> GetDistToCenter() const;
/*!
* Used to set the vertex data used by this mesh. Calling this function will clear all other data in this object.
* \param in A vector containing the vertices to replace those in the mesh with. Note that there is no way to set vertices one at a time, they must be sent in one batch.
*/
NIFLIB_API void SetVertices( const vector<Vector3> & in );
/*!
* Used to set the normal data used by this mesh. The size of the vector must either be zero, or the same as the vertex count retrieved with the IShapeData::GetVertexCount function or the function will throw an exception.
* \param in A vector containing the normals to replace those in the mesh with. Note that there is no way to set normals one at a time, they must be sent in one batch. Use an empty vector to signify that this mesh will not be using normals.
*/
NIFLIB_API void SetNormals( const vector<Vector3> & in );
/*!
* Used to sets the distance to center for vertices. The size of the vector must either be zero, or the same as the vertex count retrieved with the IShapeData::GetVertexCount function or the function will throw an exception.
* \param in A vector containing the normals to replace those in the mesh with. Note that there is no way to set normals one at a time, they must be sent in one batch. Use an empty vector to signify that this mesh will not be using normals.
*/
NIFLIB_API void SetDistToCenter( const vector<float> & in );
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
protected: protected:
/*! Unknown. */ /*! Unknown. */
......
...@@ -69,6 +69,18 @@ public: ...@@ -69,6 +69,18 @@ public:
*/ */
NIFLIB_API void SetMaterial( HavokMaterial value ); NIFLIB_API void SetMaterial( HavokMaterial value );
/*!
* Gets the capsule's radius.
* \return The radius of the capsule.
*/
NIFLIB_API float GetRadius() const;
/*!
* Sets the capsule's radius.
* \param[in] value The new radius for the capsule.
*/
NIFLIB_API void SetRadius( float value );
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
protected: protected:
/*! The shape's material. */ /*! The shape's material. */
......
...@@ -178,4 +178,60 @@ vector<Vector3> bhkConvexVerticesShape::GetVertices() const { ...@@ -178,4 +178,60 @@ vector<Vector3> bhkConvexVerticesShape::GetVertices() const {
} }
return good_vertices; return good_vertices;
} }
vector<float> bhkConvexVerticesShape::GetDistToCenter() const
{
//Remove any bad triangles
vector<float> good_dist;
for ( unsigned i = 0; i < normals.size(); ++i ) {
good_dist.push_back(normals[i][3]);
}
return good_dist;
}
void bhkConvexVerticesShape::SetVertices( const vector<Vector3> & in )
{
int size = in.size();
vertices.resize(size);
for (int i=0; i<size; ++i)
{
Float4 &f = vertices[i];
const Vector3 &v = in[i];
f[0] = v.x;
f[1] = v.y;
f[2] = v.z;
f[3] = 0.0f;
}
}
void bhkConvexVerticesShape::SetNormals( const vector<Vector3> & in )
{
int size = in.size();
normals.resize(size);
for (int i=0; i<size; ++i)
{
Float4 &f = normals[i];
const Vector3 &v = in[i];
f[0] = v.x;
f[1] = v.y;
f[2] = v.z;
f[3] = 0.0f;
}
}
void bhkConvexVerticesShape::SetDistToCenter( const vector<float> & in )
{
if ( in.size() != normals.size() ) {
throw runtime_error("Distance vector size does not match normal size.");
}
int size = in.size();
normals.resize(size);
for (int i=0; i<size; ++i)
{
Float4 &f = normals[i];
f[3] = in[i];
}
}
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
...@@ -102,4 +102,13 @@ void bhkSphereRepShape::SetMaterial( HavokMaterial value ) { ...@@ -102,4 +102,13 @@ void bhkSphereRepShape::SetMaterial( HavokMaterial value ) {
material = value; material = value;
} }
float bhkSphereRepShape::GetRadius() const {
return radius;
}
void bhkSphereRepShape::SetRadius( float value ) {
radius = value;
}
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment