Fail to compile or link to svn

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Fail to compile or link to svn

Postby JoeJ » Wed Nov 23, 2011 6:31 pm

...i'll open an new thread, sync to newest version didn't help.
I'm sure i make a mistake, as always when it comes to linking or compiling other projects, maybe smeone else can help too...

My problem: I want to update to actual Open Source version. Download works well.
I compile the project in: coreLibrary_300\projets\windows\project_vs2008 which generates newton_d.lib, i link to this in my project.
Also i include newton.h from: newton-dynamics-read-only\packages

I get linker errors like:
1>Physics.obj : error LNK2019: unresolved external symbol __imp__NewtonBodySetTorque referenced in function "void __cdecl ForceAndTorqueCallback(struct NewtonBody const *,float,int)" (?ForceAndTorqueCallback@@YAXPBUNewtonBody@@MH@Z)
1>Physics.obj : error LNK2019: unresolved external symbol __imp__NewtonBodyGetMatrix referenced in function "void __cdecl ForceAndTorqueCallback(struct NewtonBody const *,float,int)" (?ForceAndTorqueCallback@@YAXPBUNewtonBody@@MH@Z)
1>Ragdoll.obj : error LNK2001: unresolved external symbol __imp__NewtonBodyGetMatrix
...

Is there a step that i'm missing? I don't need a dll, right? If so - how can i create it?


As an alternative i try to add all files from core+physics+newton to my project, and add their directories to the Additional Inclue Directories.
But now i get 1000s of compiler errors.
Most of them say something like "assert is undefined",
and also the intristics seem unavailable ("mm*128*... undefined") - is there a preprocessor define which turns them off for now?


Problems remain if i try 2.00
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby JoeJ » Thu Nov 24, 2011 3:59 am

Linking method is working now.
I changed the configuration in newton project to debugDll, got dll too and now everything is fine.

But i'd prefer to include newton source in my own project directly. Any help welcome.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby JoeJ » Thu Nov 24, 2011 7:31 am

There seems to be a bug in raycasting (3.00).
assert.JPG
assert.JPG (212.01 KiB) Viewed 5591 times


in lines
Code: Select all
maxParam = param;
ray.Reset (maxParam);

param is zero, so a div by 0 follows.

with 2.00 there's no break like that, but it seems the raycast does not hit anything.

My scene uses all kinds of collision primitives, but no static mesh or heightfiled.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby Julio Jerez » Thu Nov 24, 2011 10:52 am

all of the library soudl build correcly, I do no knwo whay you can no include the project files, I use then as plib, not as lib

also is the ray cast constent, how can I reproduce it?

are you saying that in rest param, if param, become zero teh coe will go bunk, but that thjsi doe no happens in 2.00?
I will revsit, that.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby JoeJ » Thu Nov 24, 2011 12:14 pm

While working on other stuff i've changed some global test flag.
So i've disabled a part of the raycast setup, which explains why it didn't work at all in any version.
Now it's working fine, but i'm still able to reproduce the crash.

I call: NewtonWorldRayCast (world, &p0[0], &p1[0], nRayCastFilter, (void*)&rc, nRayCastPrefilter);

p0 = (0,0,0)
p1 = (0,0,-1)

Those coordinates are a requirement to reproduce, anything is fine if i use other values.
And beside that, my Scene might count approx. 70 bodies.
I've tried to remove some of them, and had luck with a number of 20 boring boxes. In that case there's no crash.

So i guess, if there is a bug and it isn't my fault, it needs those coordinates and a specific state of the tree used to speed up casting.
I'll keep a copy of my project at that state.
If it really gives you headakes, i could shrink it down and send it to you, but that would be a very lot of work.
I'd prefer to serealize the scene, if that gives sense.

Another problem i have after the update is a debug assertion failed when quitting my app: dgMemory.cpp, Line 38, Expression GetCount()==0
But i guess this is because i was too lazy to free up any memory on exit.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby Julio Jerez » Thu Nov 24, 2011 12:20 pm

The ray cast soudl never ever fail.
the ray cast of the broadphasein core 300 is the same ray cast fo the collision tree and the scene collision in core200, but here it cast shapes instead of polygons,

those bug are had to find without a way to reproduce it. can you send me the test?


the assert on exit is because you are not realsing the collision shape after you use them.
I sugets you make a scne with one object, and see whaer to create the body.

basically teh code to crate a boy is liek this

-create collison shape
-create all bodies you want with thsi shape.
-release shape
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby JoeJ » Thu Nov 24, 2011 2:29 pm

The good thing is: I've reduced the scene to 1 static ground box, 20 boxes and one cylinder above it.
The bad is: Boxes and cylinder are in the air initially. The Boxes fall on the ground and the cylinder falls on the boxes.
After that the scene is in the state where the crash happens. If i start the scene with no gravity, no crash.

I think you'll be able to reproduce with given code, otherwise let me know...
See the attache image for how the scene should look like after the cylinder collided with the boxes.
When the boxes are at rest, the raycast using given coords should reproduce the crash.
The cylinder is still moving, but that does not have effect.

my machine is a i7 930 or 730?, however, older generation quad core.
Running in debug mode, without advise newton to do multithreading.

raycastScene.jpg
raycastScene.jpg (180.08 KiB) Viewed 5574 times





Code: Select all
void PhysicsWorld::CreateTestScene () // PhysicsWorld is derived from NewtonPhysics, given below
{
   float cubeHalf = 0.5f;
   float extraHeight = cubeHalf*2;

   sMat4 trans;
   trans.Identity();

   Shape *groundShape = CreateBoxShape (sVec3 (100, 10, 100));
   trans.Identity();
   *trans.Translation() = sVec3 (0,-5,0);
   CreateRigidBody (0, trans, groundShape);
   ReleaseShape (groundShape);


   Shape *cylShape = CreateCylinderShape (8, 2);
   trans.Identity();
   *trans.Translation() = sVec3 (0,60,0);
   CreateRigidBody (1, trans, cylShape);
   ReleaseShape (cylShape);

   if (1)
   {

      for (int i=0; i<20; i++)
      {
         sVec3 dim (1, 1 + (float) (i%5) * 0.8f, 1 + (float) i * 0.8f);
         Shape *stackShape = CreateBoxShape (dim);
         trans.Identity();
         trans.Rotation()->FromEulerZYX (sVec3(0, (float) (i) * 0.05f, 0));
         *trans.Translation() = sVec3 (i * 5.0f - 47.5f, 20, 0);
         CreateRigidBody (1, trans, stackShape);
         ReleaseShape (stackShape);
      }

   }
}

void PhysicsWorld::Step ()
{
   NewtonUpdate (world, 0.024999000); // nicely simplyfied
}

Body* PhysicsWorld::CreateRigidBody (float mass, sMat4 &trans, Shape *shape) // Body == NewtonBody
   {
      Body *body = ((NewtonPhysics*)this)->CreateRigidBody (mass, trans, shape);
      if (body)
      {
         const float damp = 0.01f;
         NewtonBodySetAngularDamping (body, &damp);
         NewtonBodySetLinearDamping (body, 0.01f);
         //NewtonBodyG
         BodyData *data = new BodyData;
         //todo: check alloc
         NewtonBodySetUserData (body, (void*) data);
         NewtonBodySetForceAndTorqueCallback (body, ForceAndTorqueCallback);
         bodies.push_back (body);

         //BodySetMaterial (body, 0);
      }
      return body;
   }



class NewtonPhysics
{
public:

   NewtonWorld* world;
   
NewtonCollision* CreateBoxShape (sVec3 &dim, sMat4 *offset = 0)
   {
      return NewtonCreateBox (world, dim.x(), dim.y(), dim.z(), SERIALIZE_ID_BOX, &(*offset)[0][0]);
   }

   NewtonCollision* CreateCylinderShape (float height, float radius, sMat4 *offset = 0)
   {
      return NewtonCreateCylinder (world, radius, height, SERIALIZE_ID_CYLINDER, &(*offset)[0][0]);
   }

// because i initially used a single interface for both bullet and newton, i use functions like this, they do nothing special, simply what you expect
void ReleaseShape (NewtonCollision* shape)
   {
      NewtonReleaseCollision (world, shape);
   }


void CreateWorld ()
   {
      // set the memory allocators
      NewtonSetMemorySystem (AllocMemory, FreeMemory);

      // create the Newton World
      world = NewtonCreate ();
      

      // use the standard x87 floating point model 
      NewtonSetPlatformArchitecture (world, 0);

      // set a fix world size
      v3f minSize (-1000.0f, -1000.0f, -1000.0f);
      v3f maxSize ( 1000.0f,  1000.0f,  1000.0f);
      NewtonSetWorldSize (world, &minSize[0], &maxSize[0]);

      NewtonSetSolverModel (world, 4);
   }

   NewtonBody* CreateRigidBody (float mass, sMat4 &trans, NewtonCollision *shape)
   {
      float origin[4];
      float inertia[4];
      NewtonBody* body;

      body = NewtonCreateBody (world, shape, &trans[0][0]);//

      NewtonConvexCollisionCalculateInertialMatrix (shape, &inertia[0], &origin[0]);   

      NewtonBodySetMassMatrix (body, mass, mass * inertia[0], mass * inertia[1], mass * inertia[2]);

      NewtonBodySetCentreOfMass (body, &origin[0]);

      return body;
   }

// let me know if something's missing...
}




void ForceAndTorqueCallback (const NewtonBody* body, dFloat timestep, int threadIndex)
{
   dFloat Ixx;
   dFloat Iyy;
   dFloat Izz;
   dFloat mass;

   NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
   
   sVec3 force (0.0f, mass * -40.0f, 0.0f);
   NewtonBodyAddForce (body, &force[0]);
   
}


// this is from the free sony math lib coming with bullet, that rotation is required to reproduce, but this 3x3 correspondents to the top left of a dgMatrix with equal ordering
inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ )
{
    float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1;
    sX = sinf( radiansXYZ.getX() );
    cX = cosf( radiansXYZ.getX() );
    sY = sinf( radiansXYZ.getY() );
    cY = cosf( radiansXYZ.getY() );
    sZ = sinf( radiansXYZ.getZ() );
    cZ = cosf( radiansXYZ.getZ() );
    tmp0 = ( cZ * sY );
    tmp1 = ( sZ * sY );
    return Matrix3(
        Vector3( ( cZ * cY ), ( sZ * cY ), -sY ),
        Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ),
        Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) )
    );
}


// raycast...

struct RayCastInfo
{
   float param;
   sVec3 normal;
   Body* hitBody;
   
   RayCastInfo ()
   {
      param = 1.1f;
      hitBody = 0;
   }
};

unsigned nRayCastPrefilter (const NewtonBody* body, const NewtonCollision* collision, void* userData)
{
   // ray cannot pick trigger volumes
   return NewtonCollisionIsTriggerVolume(collision) ? 0 : 1;
}

float nRayCastFilter (const NewtonBody* body, const float* normal, int collisionID, void* userData, float intersectParam)
{
   float mass;
   float Ixx;
   float Iyy;
   float Izz;

   NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);

   RayCastInfo *rc = (RayCastInfo*) userData;
   if (intersectParam < rc->param)
   {
      rc->param = intersectParam;
      rc->hitBody = (Body*) body;
      sMat4 m; BodyGetMatrix ((Body*)body, m);
      rc->normal = m.Unrotate (*((sVec3*)normal));
   }
   return intersectParam;
}


User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby Julio Jerez » Thu Nov 24, 2011 2:52 pm

but that code is fragments from you own classes, it will take me lot of time to make the changes to reproduce the bug.
you have Shepe, Body, sMatrix, ... I do not have any of that.

I get all this errors
1>..\..\sdkDemos\demos\SoftBodies.cpp(23) : error C2653: 'PhysicsWorld' : is not a class or namespace name
1>..\..\sdkDemos\demos\SoftBodies.cpp(28) : error C2065: 'sMat4' : undeclared identifier
1>..\..\sdkDemos\demos\SoftBodies.cpp(28) : error C2146: syntax error : missing ';' before identifier 'trans'
1>..\..\sdkDemos\demos\SoftBodies.cpp(28) : error C2065: 'trans' : undeclared identifier
1>..\..\sdkDemos\demos\SoftBodies.cpp(29) : error C2065: 'trans' : undeclared identifier
1>..\..\sdkDemos\demos\SoftBodies.cpp(29) : error C2228: left of '.Identity' must have class/struct/union


and also I do not underntan what you mean with the CPU and the mutithread,
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby Julio Jerez » Thu Nov 24, 2011 2:58 pm

if you link to the Newton.dll you can send me a running demo, and I can debug it by attaching to the dll in my side.

that wa you do not have to recraete anythong. it is eassy for you and eassy for my.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby JoeJ » Thu Nov 24, 2011 4:27 pm

Julio Jerez wrote:I can debug it by attaching to the dll in my side


i didn't know that's possible, i've sent you the exe to your gmail.
Iportant: it must lie in this folder:
C:\dev\pengII\pengII\Debug\pengII.exe
It's linked to newton_d.dll.

In case of no luck:
typedef NewtonCollision Shape;
typedef NewtonBody Body;
typedef NewtonWorld World;
... i renamed those things to build a common interface for newton and bullet
sMat4 is the same as dgMatrix, sVec3 as dgVector.
It's for sure some work to convert the code to your testbed, but much less than for me to remove the tons of garbage and rocken scientifics from my project :lol:
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby JoeJ » Thu Nov 24, 2011 5:07 pm

Email adress from google code failed. Can you post or PM?
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby Julio Jerez » Thu Nov 24, 2011 6:36 pm

I did not get the email, you me to send a PM?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby JoeJ » Fri Nov 25, 2011 3:25 am

It seems there's a problem with my hotmail, i've tried again from another account at work. Check again...
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby Julio Jerez » Fri Nov 25, 2011 8:35 am

Now I got tow email but the but say this

FILE QUARANTINED

The original contents of this file have been replaced with
this message because of its characteristics.
File name: 'pengII.part02.rar'
Virus name: 'CorruptedCompressedFile'


can you upload it to one of those free file share places that allow big files for a few days.
you cna put a paswprd on teh file, if you do no want othe people to see it.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby JoeJ » Fri Nov 25, 2011 8:53 am

... what a mess.

I've sent you a PM with the link.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests