NewtonCollisionCollide() doesn't seem to work

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

NewtonCollisionCollide() doesn't seem to work

Postby agi_shi » Sat Apr 30, 2011 9:25 am

Hey Julio, I'm sorry to keep bothering you with so many questions :) But this time NewtonCollisionCollide() seems to have issues (latest SVN)

Here's my test case:
Code: Select all
#include <iostream>

#include "Newton.h"
#pragma comment(lib, "newton.lib")

int main()
{
   // pretty output for floats
   std::cout.setf(std::ios::fixed);
   std::cout.precision(3);

   NewtonWorld* world = NewtonCreate();

   // identity matrix
   float ident[] =
   {
      1, 0, 0, 0,
      0, 1, 0, 0,
      0, 0, 1, 0,
      0, 0, 0, 1
   };
   // 1x1x1 box
   NewtonCollision* col = NewtonCreateBox(world, 1, 1, 1, 0, ident);

   const int NUM_CONTACTS = 8;
   float contacts[NUM_CONTACTS * 3];
   float normals[NUM_CONTACTS * 3];
   float penetrations[NUM_CONTACTS];

   // matrix for the colliding "body"
   float matrix[] =
   {
      1, 0, 0, 0,
      0, 1, 0, 0,
      0, 0, 1, 0,
      0, 0, 0, 1
   };
   const float INTERVAL = 0.1f;
   for (float x = -2; x <= 2; x += INTERVAL)
   {
      matrix[12] = x; // set x position
      int ret = NewtonCollisionCollide(world, NUM_CONTACTS, col, ident, col, matrix, contacts, normals, penetrations, 0);
      std::cout << "x: " << x << "\tcollision:\t" << ((ret > 0) ? "yes" : "no") << std::endl;
   }

   NewtonReleaseCollision(world, col);
   NewtonDestroy(world);
}

It creates a 1x1x1 box collision, and tests for a collision with one placed at 0,0,0 and the other moving on the x axis from x=-2 to x=2.

Unfortunately, NewtonCollisionCollide() seems to always return 0 no matter what I try. For example, the above test code produces this output:
Code: Select all
x: -2.000       collision:      no
x: -1.900       collision:      no
x: -1.800       collision:      no
x: -1.700       collision:      no
x: -1.600       collision:      no
x: -1.500       collision:      no
x: -1.400       collision:      no
x: -1.300       collision:      no
x: -1.200       collision:      no
x: -1.100       collision:      no
x: -1.000       collision:      no
x: -0.900       collision:      no
x: -0.800       collision:      no
x: -0.700       collision:      no
x: -0.600       collision:      no
x: -0.500       collision:      no
x: -0.400       collision:      no
x: -0.300       collision:      no
x: -0.200       collision:      no
x: -0.100       collision:      no
x: 0.000        collision:      no
x: 0.100        collision:      no
x: 0.200        collision:      no
x: 0.300        collision:      no
x: 0.400        collision:      no
x: 0.500        collision:      no
x: 0.600        collision:      no
x: 0.700        collision:      no
x: 0.800        collision:      no
x: 0.900        collision:      no
x: 1.000        collision:      no
x: 1.100        collision:      no
x: 1.200        collision:      no
x: 1.300        collision:      no
x: 1.400        collision:      no
x: 1.500        collision:      no
x: 1.600        collision:      no
x: 1.700        collision:      no
x: 1.800        collision:      no
x: 1.900        collision:      no


Any ideas? Am I doing something wrong, maybe?
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: NewtonCollisionCollide() doesn't seem to work

Postby agi_shi » Sat Apr 30, 2011 9:59 am

I just checked the source:
Code: Select all
dgInt32 dgWorld::Collide (dgCollision* const collisionA, const dgMatrix& matrixA, dgCollision* const collisionB, const dgMatrix& matrixB, dgTriplex* const points, dgTriplex* const normals, dgFloat32* const penetration, dgInt32 maxSize, dgInt32 threadIndex)
{
_ASSERTE (0);
return 0;
/*
   bool isTriggerA;
   bool isTriggerB;
   dgInt32 count;

   (etc etc)

Is this intended? If I uncomment it, I receive compile errors regarding Newton internals that I am not familiar with (pair.m_contactBuffer for example). Any ideas?

I need NewtonCollisionCollide() to check for collisions outside of a NewtonUpdate() call, I don't want to create a body with a contact callback.
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: NewtonCollisionCollide() doesn't seem to work

Postby Julio Jerez » Sat Apr 30, 2011 12:13 pm

Oh that is wrong, I will check it.

Is the function also commented out in 2.33 build?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionCollide() doesn't seem to work

Postby agi_shi » Sun May 01, 2011 12:54 am

Julio Jerez wrote:Oh that is wrong, I will check it.

Is the function also commented out in 2.33 build?

I'm not sure - which one is the 2.33 build? I'm working with the latest SVN as usual because it's the quickest when it comes to ironing out bugs :mrgreen:
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 3 guests

cron