Kinematic and dynamic body: interaction?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Kinematic and dynamic body: interaction?

Postby Julio Jerez » Wed May 08, 2013 9:30 am

I have windows 7 32 bit yes, but I cannot install it on my laptop because I already have installed it on this system which is 64 bit.
let up see if it also happens on XP.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic and dynamic body: interaction?

Postby StabInTheDarkSoft » Wed May 08, 2013 9:41 am

Ok let me clarify your 32 bit "demosSandbox.exe" from the SVN repository was only
crashing when the player first interacted with the bridge. Then I rebuilt and it does not crash.
The 64bit "demosSandbox.exe" only crashes after several interactions of the player with the bridge.
Everything rebuilds okay for me using VS 2010 Professional edition on Windows 7 64.
StabInTheDarkSoft
 
Posts: 2
Joined: Mon Apr 08, 2013 9:17 am

Re: Kinematic and dynamic body: interaction?

Postby Enclave » Wed May 08, 2013 9:50 am

You can install windows 7 on VMware, may be there this error happens.

What is the "m_attrib[0]" class? where is initialised and what data? I want to trace code from that place to see, who is destroy the data.

I mean this function:

Code: Select all
void dgMeshEffect::ApplyTransform (const dgMatrix& matrix)
{
   matrix.TransformTriplex(&m_points[0].m_x, sizeof (dgBigVector), &m_points[0].m_x, sizeof (dgBigVector), m_pointCount);
   matrix.TransformTriplex(&m_attrib[0].m_vertex.m_x, sizeof (dgVertexAtribute), &m_attrib[0].m_vertex.m_x, sizeof (dgVertexAtribute), m_atribCount);

   dgMatrix rotation ((matrix.Inverse4x4()).Transpose4X4());
   for (dgInt32 i = 0; i < m_atribCount; i ++) {
      dgVector n (dgFloat32 (m_attrib[i].m_normal_x), dgFloat32 (m_attrib[i].m_normal_y), dgFloat32 (m_attrib[i].m_normal_z), dgFloat32 (0.0f));
      n = rotation.RotateVector(n);
      dgAssert ((n % n) > dgFloat32 (0.0f));
      n = n.Scale (dgRsqrt (n % n));
      m_attrib[i].m_normal_x = n.m_x;
      m_attrib[i].m_normal_y = n.m_y;
      m_attrib[i].m_normal_z = n.m_z;
   }
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: Kinematic and dynamic body: interaction?

Postby Julio Jerez » Wed May 08, 2013 10:06 am

In file c:\Users\Julio\Desktop\newton-dynamics\coreLibrary_300\source\meshUtil\dgMeshEffect1.cpp

function:
void dgMeshEffect::BuildFromVertexListIndexList(
dgInt32 faceCount, const dgInt32* const faceIndexCount, const dgInt32* const faceMaterialIndex,
const dgFloat32* const vertex, dgInt32 vertexStrideInBytes, const dgInt32* const vertexIndex,
const dgFloat32* const normal, dgInt32 normalStrideInBytes, const dgInt32* const normalIndex,
const dgFloat32* const uv0, dgInt32 uv0StrideInBytes, const dgInt32* const uv0Index,
const dgFloat32* const uv1, dgInt32 uv1StrideInBytes, const dgInt32* const uv1Index)

you can set a break point at line 2260
after the code start to load
LoadHangingBridge(scene, triggerManager, sceneCollision, "hangingBridge.ngd", bridgeMatrix, playGroundBody);

the I will hit that line and by stepping on the loop you can see how the loop populate m_attribute array one enetry at a time by calling AddAtribute(point);

if there is a operation system bug it may be in function AddAtribute, which expand the memory array if is goes out of bounds.

void dgMeshEffect::AddAtribute (const dgVertexAtribute& attib)
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic and dynamic body: interaction?

Postby Julio Jerez » Wed May 08, 2013 10:33 am

Oh I think I might have figure out.

I added this code

Code: Select all
// Enclave  look here !!!
// sanity check of  m_atrrib
for (int i = 0; i < m_atribCount; i ++)
{
   dgVector n (dgFloat32 (m_attrib[i].m_normal_x), dgFloat32 (m_attrib[i].m_normal_y), dgFloat32 (m_attrib[i].m_normal_z), 0.0f);
   dgFloat32 mag2 = n % n;
   dgAssert (mag2 > 0.99f);
   dgAssert (mag2 < 1.01f);
}



to function
Code: Select all
void dgMeshEffect::BuildFromVertexListIndexList(
   dgInt32 faceCount, const dgInt32* const faceIndexCount, const dgInt32* const faceMaterialIndex,
   const dgFloat32* const vertex, dgInt32 vertexStrideInBytes, const dgInt32* const vertexIndex,
   const dgFloat32* const normal, dgInt32  normalStrideInBytes, const dgInt32* const normalIndex,
   const dgFloat32* const uv0, dgInt32  uv0StrideInBytes, const dgInt32* const uv0Index,
   const dgFloat32* const uv1, dgInt32  uv1StrideInBytes, const dgInt32* const uv1Index)


and the assert do trigger with normal of zero length.
It turn out that some mesh are create procedurally and do no fill the normal and UV array.

but before this was no triggering any assert or crash and I believe the reason is that WxWidget must be setting the float expectation on an now if a float goes wrong the exception is trigger.
give me few minutes to make sure that normal are never of zero length.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic and dynamic body: interaction?

Postby Julio Jerez » Wed May 08, 2013 10:39 am

Ok sync to svn again I adde code that test if a normal is 0,0,0 and if so it set it to 0, 1, 0
this will guarantee that there are no face with zero vertex normal.

if this works in your system then we know that wxWidget, or may some other app is setting float exceptions on. and I will have to figure out how to set that off,
or perhaps this si better because it makes the code even cleaner.

edit:
sync again I move the set to a better location. that way all call to set m_attib will make sure that normal does not has zero length
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic and dynamic body: interaction?

Postby Enclave » Wed May 08, 2013 11:32 am

Ok, i test it.
Now we get an another error, it is no assert on step 13 anymore.

look to the screenshots.

is this a floating bug?

p.s.
This looks like when you add the code, you change some address (or offset) for which data are destroyed
Attachments
error6.png
a new place for bug
error6.png (110.21 KiB) Viewed 3408 times
error5.png
error5.png (113.59 KiB) Viewed 3408 times
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: Kinematic and dynamic body: interaction?

Postby JoeJ » Wed May 08, 2013 11:47 am

I'm back home - same here. I think i've found something:

Code: Select all
void Friction (DemoEntityManager* const scene)
{
   // load the skybox
   scene->CreateSkyBox();


   // load the scene from a ngd file format
char fileName[2048];
GetWorkingFileName ("frictionDemo.ngd", fileName);
// this returns: +      fileName   0x0018f3ec "c:\\dev\\newton-dynamics-read-only\\applications/media/frictionDemo.ngd"   char[2048]

   //scene->LoadScene (fileName); // comenting this out and replacing with hardcoded path:
   scene->LoadScene ("C:\\dev\\newton-dynamics-read-only\\applications\\media");




Changing to hardcoded path let the demo continue after scene->LoadScene(), followed by different but similar problems.
So maybe some string library used in GetWorkingFileName is different vc2012 <-> vc2008.
Maybe the difference is dll and system dependent too? (Enclave crashed at the same point as me iin above post)
I really hate strings :)

EDIT: Oops - forgot to add "frictionDemo.ngd" to the hardcoded path - forget the above... :(
Last edited by JoeJ on Wed May 08, 2013 11:54 am, edited 1 time in total.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Kinematic and dynamic body: interaction?

Postby Julio Jerez » Wed May 08, 2013 11:52 am

no this is a random error, IO do no know what is casing it, because those function has no changed.
The Jacobi function I have being using for almost 25 years and has never fail

wait until the update finish in my laptop, let us hop that I can recreate this problem on xp, of not I do no know what is wrong .

I have no made the many change for this to happen, My guess is that there is nor bug and wxWidet 2.9.4 does not work in you machine

this oen of the reason that 2 year ago a abandome wxWdge, because all the random crashes, but I could not find any substitute that is cross platform.
There is no way those crashes make sense to me.

I have win7 32 but the license does not let me use in more than one machine, therefore I can no test this on windows 7 32 bit.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic and dynamic body: interaction?

Postby Julio Jerez » Wed May 08, 2013 11:59 am

Joe that;s one o fteh function than I have to change l\for the OSx port

Code: Select all
void GetWorkingFileName (const char* const name, char* const outPathName)
{
   #if defined (_MSC_VER)

      //GetAplicationDirectory (appPath);
      char appPath [256];
      GetModuleFileNameA(NULL, appPath, sizeof (appPath));
      strlwr (appPath);

      char* const ptr = strstr (appPath, "applications");
      ptr [0] = 0;
      sprintf (outPathName, "%sapplications/media/%s", appPath, name);

   #elif defined(_MACOSX_VER)
        char tmp[2048];
      CFURLRef appURL (CFBundleCopyBundleURL(CFBundleGetMainBundle()));
        CFStringRef filePath (CFURLCopyFileSystemPath (appURL, kCFURLPOSIXPathStyle));
        CFStringGetCString (filePath, tmp, PATH_MAX, kCFStringEncodingUTF8);
        char* const ptr = strstr (tmp, "applications");
        ptr [0] = 0;
        sprintf (outPathName, "%sapplications/media/%s", tmp, name);

      // Clean up
      CFRelease( appURL );
      CFRelease( filePath );
   
   #elif defined(_POSIX_VER)

      char id[2048];
      char path[2048];
      char *end;

      sprintf(id, "/proc/%d/exe", getpid());
      memset (path, 0, sizeof (path));
      readlink(id, path, 1024);
      char* const end = strrchr (path, '//');
      *end = 0;
      sprintf (outPathName, "%s/bin/%s", path, name);

   #else
      #error  "error: neet to implement \"GetWorkingFileName\" here for thsi platform"
   #endif
}
 


can you set a break point and see if the path that generates in outPathName is valid

in my machine the path only have one back slatch: c:\users\julio\desktop\newton-dynamics\applications/media/platformBridge.ngd

can you check is the file is open does no fail after that
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic and dynamic body: interaction?

Postby Enclave » Wed May 08, 2013 12:08 pm

:( :( :(

Here is another picture
Again division by zero?

I have win7 32 but the license does not let me use in more than one machine, therefore I can no test this on windows 7 32 bit.


Hmm..You do not have to activate it, it will works normally at least 3 days.
Attachments
error7.png
error7.png (116.77 KiB) Viewed 3403 times
Last edited by Enclave on Wed May 08, 2013 2:20 pm, edited 1 time in total.
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

Re: Kinematic and dynamic body: interaction?

Postby JoeJ » Wed May 08, 2013 12:22 pm

Julio Jerez wrote:can you check is the file is open does no fail after that


for me it's displayed as
+ _filename 0x06a08ee0 "c:\\dev\\newton-dynamics-read-only\\applications/media/frictionDemo.ngd" const char *
with double backslash at the first and single slash at the second part.
But the file loads ok - it was my mistake that i've used wrong hardcoded path, see EDIT in post.

I followed the debugger further, using friction demo as default, i get to

static void MakeSceneNodeMatricesLocalToNodeParent (dScene* const scene)
and here the first call to nodeInfo->SetTransform(localMatrix) alerts the corruption.
I remember now, taht's EXACTLY the same as 1-2 months ago.
Looking at the function i did not see anything that could cause stack corruption (and JacobiDiagonalization is not called in my case).
Thus i concluded that another thread does something wrong but no proof for that.

You can be pretty sure the bug is older, hopefully vc2012 reproduces for you.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Kinematic and dynamic body: interaction?

Postby Julio Jerez » Wed May 08, 2013 12:40 pm

so are you saying that if I download VS 2012 express I will be able to reproduce this?
even in this system?


what you are doing is playing the fiction demo an flowing the code until it hit that function and there is crashes because ether is corrupted data?
static void MakeSceneNodeMatricesLocalToNodeParent (dScene* const scene)

I will do that then but it have to be tomorrow or tonight, I am very late for work now.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Kinematic and dynamic body: interaction?

Postby JoeJ » Wed May 08, 2013 12:53 pm

Julio Jerez wrote:so are you saying that if I download VS 2012 express I will be able to reproduce this?


Hopefully, both machines i tried are Win7 x64.
If i do something to avoid stack alert, like:

void dSceneNodeInfo::SetTransform (const dMatrix& matrix)
{
dMatrix transform;
//matrix.PolarDecomposition(transform, m_scale, m_eigenScaleAxis);
transform = GetIdentityMatrix();
m_position = matrix.m_posit;
// m_euler = transform.GetXYZ_EulerAngles ();
m_euler = transform.GetEulerAngles ();
}

... I get the stack alert at another place where it makes no sense, like in quat slerp.
If you're sure that there are no other threads at this point, maybe there's something wrong with scene nodes.
Most probably a tiny but hard to find thingy.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Kinematic and dynamic body: interaction?

Postby Enclave » Wed May 08, 2013 1:37 pm

JoeJ

I just run sandbox on yet another computer, my desktop. On WinXP it works ok, but on windows 7 64 the same error happens.

Is the windows 7 bug???

. I get the stack alert at another place where it makes no sense, like in quat slerp.


Yes, i get the same.
Enclave
 
Posts: 81
Joined: Wed May 01, 2013 6:00 am

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests