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?

3 posts / 0 nouveau(x)
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

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;