Jump to content

[SOLVED] error can't convert vec3 to dvec3


photo

Recommended Posts

hi:

   I'm running on the double precision simulation version. I found it's complicated to handle the vec3 to dvec3 or mat4 to dmat4 similiar.

   if i run the following

#ifdef USE_DOUBLE
	dvec3 vPos=dvec3(0);
#else
	vec3 vPos=vec3(0);
#endif
int idx1=mesh.getIndex(0);
int idx2=mesh.getIndex(1);

vPos=(mesh.getVertex(idx1)+mesh.getVertex(idx2))*0.5f;

Node joint=add_editor(Unigine::createBox(vec3(1.0f)));
joint.setPosition(vPos);

i will get an can't convert vec3 to dvec3 error on the last line.

but if i change vPos to 

vPos+=mesh.getVertex(idx1)+mesh.getVertex(idx2);
vPos*=0.5f;

it works fine.

i need to know how to make it work for both single and double precision in uniginescript? or i have to stick with one?

Link to comment

Hi, you can use special "Scalar", "Vec3", "Mat4" types for define vectors and matrices. This types automatically detected from double or float coordinates precision. This types are defined in a "data/core/unigne.h".

#include <unigine.h>

Node dummy = new NodeDummy();
// double - Vec3 is dvec3, else Vec3 is vec3
Vec3 pos = Vec3_one;
dummy.setPosition(pos);
Link to comment

Hi Natalia:

Thanks for you help. Could you try node.setPosition(node2.getPosition()) in double precision build? It seems have the issue too.

Link to comment

try the following code. mesh is a ObjectMeshDynamic. basically i want to set an object to that vertex position.

 

node.setPosition(mesh.getVertex(0));

Link to comment

Hi,

 

The returning type of getVertext() is vec3, so this value without modifications can be used only with float precision builds.

 

Try to pass Vec3 constructor explicit to the node.setPosition() function. For example:

node.setPosition(Vec3(mesh.getVertex(0)));

Thanks!

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...