Newton 2 compiler

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Newton 2 compiler

Postby freevryheid » Sat Dec 06, 2008 12:25 pm

No biggie but I notice that now a c++ compiler is required for the library given the new structure in the Newton.h header i.e. NewtonCollisionInfoRecordTag

Do I need this structure or how can I convert the header to still compile with c. As a side project I'm trying to convert the header to use the library with a BASIC compiler which is proving tricky with the new header. Thanks.
freevryheid
 
Posts: 7
Joined: Sat Oct 25, 2008 9:22 pm

Re: Newton 2 compiler

Postby Julio Jerez » Sat Dec 06, 2008 12:44 pm

you can just change NewtonCollisionInfoRecordTag to use c unions.

I have to make like that because some platforms like the Mac, do not allow for simple c unions.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2 compiler

Postby freevryheid » Sat Dec 06, 2008 3:56 pm

Thanks Julio

Damn Macs :lol: I'm on a Linux PC and have never used unions (simple or not). Could you please expand on how to convert the header. Is it a matter of providing a union dummy variable for the union structure? TIA
freevryheid
 
Posts: 7
Joined: Sat Oct 25, 2008 9:22 pm

Re: Newton 2 compiler

Postby Julio Jerez » Sat Dec 06, 2008 9:43 pm

Ok I remove the typedef and use only struct, please try replacing the data struture and see if it compile and let me knwo .
If is worlk I use that method.

Code: Select all
   struct NewtonCollisionInfoRecord
   {
      struct NewtonBoxParam
      {
         dFloat m_x;
         dFloat m_y;
         dFloat m_z;
      };

      struct NewtonSphereParam
      {
         dFloat m_r0;
         dFloat m_r1;
         dFloat m_r2;
      };

      struct NewtonCylinderParam
      {
         dFloat m_r0;
         dFloat m_r1;
         dFloat m_height;
      };

      struct NewtonCapsuleParam
      {
         dFloat m_r0;
         dFloat m_r1;
         dFloat m_height;
      };

      struct NewtonConeParam
      {
         dFloat m_r;
         dFloat m_height;
      };

      struct NewtonChamferCylinderParam
      {
         dFloat m_r;
         dFloat m_height;
      };

      struct NewtonConvexHullModifierParam
      {
         NewtonCollision* m_chidren;
      };


      struct NewtonCompoundCollisionParam
      {
         int m_chidrenCount;
         NewtonCollision** m_chidren;
      };

      struct NewtonHeightFieldCollisionParam
      {
         int m_width;
         int m_height;
         int m_gridsDiagonals;
         dFloat m_horizonalScale;
         dFloat m_verticalScale;
         unsigned short *m_elevation;
         char *m_atributes;
      };

      dFloat m_offsetMatrix[4][4];
      int m_collisionType;            // tag id to identify the collision primitive
      int m_referenceCount;            // the current reference count for this collision      
      int m_collisionUserID;            
      union {
         NewtonBoxParam m_box;                           
         NewtonConeParam m_cone;
         NewtonSphereParam m_sphere;
         NewtonCapsuleParam m_capsule;
         NewtonCylinderParam m_cylinder;
         NewtonChamferCylinderParam m_chamferCylinder;
         NewtonCompoundCollisionParam m_compoundCollision;
         NewtonConvexHullModifierParam m_convexHullModifier;
         NewtonHeightFieldCollisionParam m_heightField;
         dFloat m_paramArray[13];          // user define collision can use this to store information
      };
   };

   struct NewtonJointRecord
   {
      dFloat m_attachmenMatrix_0[4][4];
      dFloat m_attachmenMatrix_1[4][4];
      dFloat m_minLinearDof[3];
      dFloat m_maxLinearDof[3];
      dFloat m_minAngularDof[3];
      dFloat m_maxAngularDof[3];
      const NewtonBody* m_attachBody_0;
      const NewtonBody* m_attachBody_1;
      dFloat m_extraParameters[16];
      int   m_bodiesCollisionOn;
      char m_descriptionType[32];
   } ;


   
   struct NewtonUserMeshCollisionCollideDesc
   {
      dFloat m_boxP0[4];                  // lower bounding box of intersection query in local space
      dFloat m_boxP1[4];                  // upper bounding box of intersection query in local space
      int m_threadNumber;                  // current thread executing this query
      int   m_faceCount;                        // the application should set here how many polygons intersect the query box
      int m_vertexStrideInBytes;              // the application should set here the size of each vertex
      void* m_userData;                       // user data passed to the collision geometry at creation time
      dFloat* m_vertex;                       // the application should the pointer to the vertex array.
       int* m_userAttribute;                   // the application should set here the pointer to the user data, one for each face
      int* m_faceIndexCount;                  // the application should set here the pointer to the vertex count of each face.
      int* m_faceVertexIndex;                 // the application should set here the pointer index array for each vertex on a face.
      NewtonBody* m_objBody;                  // pointer to the colliding body
      NewtonBody* m_polySoupBody;             // pointer to the rigid body owner of this collision tree
   };

   struct NewtonWorldConvexCastReturnInfo
   {
      dFloat m_point[4];                  // collision point in global space
      dFloat m_normal[4];                  // surface normal at collision point in global space
      dFloat m_penetration;                   // contact penetration at collision point
      dFloat m_intersectionParam;            // parametric intersection parameter along ray
      int    m_contactID;                       // collision ID at contact point
      const NewtonBody* m_hitBody;         // body hit at contact point
   };
   
   struct NewtonUserMeshCollisionRayHitDesc
   {
      dFloat m_p0[4];                     // ray origin in collision local space
      dFloat m_p1[4];                         // ray destination in collision local space   
      dFloat m_normalOut[4];               // copy here the normal at the ray intersection
      int m_userIdOut;                        // copy here a user defined id for further feedback 
      void* m_userData;                       // user data passed to the collision geometry at creation time
   };

   struct NewtonHingeSliderUpdateDesc
   {
      dFloat m_accel;
      dFloat m_minFriction;
      dFloat m_maxFriction;
      dFloat m_timestep;
   } ;
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests