Allocate an array of hkVector4 - Solved

Allocate an array of hkVector4 - Solved

This code doews not compile

int numVertices = L->size();
hkVector4 * vertices = new hkVector4[numVertices];

1>Source\Scenario\GameObject.cpp(735): error C2660: 'hkVector4::operator new[]' : function does not take 1 arguments

I am trying to make a hkpConvexVerticesShape as in the manual, but the manual has a directly coded array like...

float vertices[] =
{
-2.0f, 2.0f, 1.0f, 0.0f, // v0
1.0f, 3.0f, 0.0f, 0.0f, // v1
0.0f, 1.0f, 3.0f, 0.0f, // v2
1.0f, 0.0f, 0.0f, 0.0f // v3
};

The float array from the ma nual also will not build.  Maybe a library style change?

Any ideas?

publicaciones de 3 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

Hey Richard,

The hkVector4 class has already a placement new [] operator defined like "HK_FORCE_INLINE void* HK_CALL operator new[](hk_size_t, void* p);" as a member function. This operator is hiding the "standard" new[] that you are trying to use here. You can call the "standard" new[] by using "hkVector4 * vertices = ::new hkVector4[numVertices];" (ie.: adding the global namespace operator in front of the new function).
For your second question, do you mean that
"
float vertices[] =
{
-2.0f, 2.0f, 1.0f, 0.0f, // v0
1.0f, 3.0f, 0.0f, 0.0f, // v1
0.0f, 1.0f, 3.0f, 0.0f, // v2
1.0f, 0.0f, 0.0f, 0.0f // v3
};
"
does not compile? If yes, can you tell me what is the error message you are getting? If not, are you talking about the fact that the hkStridedVertices's constructor does not take a const float but a const hkVector pointer? We will in fact need to update this code sample from the Manual.

Let me know if this helps and if you need any other information,

Cheers,
David.

David G. Developer Support Engineer Havok www.havok.com

This worked...

list * L = meshes.front();
int numVertices = L->size();
hkArrayBase vertices;
int i = 0;
for(list::iterator it = L->begin(); it != L->end(); ++it)
{
LocalPosition lpIt = *it;
lpIt.asHkVector4(vertices[i]);
i++;
}

// This structure provides the build options
hkpConvexVerticesShape::BuildConfig config;
config.m_convexRadius = 0.1f;
// Creates a convex vertices shape from these 4 vertices and the convex radius.
// By default, the shape will be shrunk during construction so that the resulting "shell" matches the
// input vertices.
hkpConvexVerticesShape* shape = new hkpConvexVerticesShape( hkStridedVertices( vertices ), config );
m_havokBody = createPhysicsHavokBody(fi, shape);
m_ownerBlock->m_havokWorld->addEntity(m_havokBody);

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya