org.odejava.collision
Class BulkContact

java.lang.Object
  extended by org.odejava.collision.Contact
      extended by org.odejava.collision.BulkContact

public class BulkContact
extends Contact

This is an extended version of standard Contact class. This solution is faster on all occasions, but real performance gains occur when iterating over a large set of contacts (several hundreds per step). Transfers contact data from ByteBuffers to local arrays in a single ByteBuffer method call. Commit writes local arrays back to ByteBuffers in a single ByteBuffer method call.

Note: when iterating collision data in a tight loop, avoid creating any objects (e.g. Vector3f, Quaternion4f), this can seriously affect your simulation performance.

Created 13.03.2004 (dd.mm.yyyy)

Author:
Jani Laakso E-mail: jani.laakso@itmill.com see http://odejava.dev.java.net

Field Summary
static int ARRAY_SIZE
           
 
Fields inherited from class org.odejava.collision.Contact
BODY_ID1, BODY_ID2, BOUNCE, BOUNCE_VEL, DEPTH, FDIR1, floatBuf, FLOATBUF_CHUNK_SIZE, GEOM_ID1, GEOM_ID2, index, INTBUF_CHUNK_SIZE, longBuf, maxContacts, MODE, MOTION1, MOTION2, MU, MU2, NORMAL, POSITION, SLIP1, SLIP2, SOFT_CFM, SOFT_ERP
 
Constructor Summary
BulkContact(LongBuffer longBuf, FloatBuffer floatBuf)
           
 
Method Summary
 void commit()
          Commit local arrays back to ByteBuffers in a single call.
 long getBodyID1()
           
 long getBodyID1(int idx)
           
 long getBodyID2()
           
 long getBodyID2(int idx)
           
 float getBounce()
           
 float getBounce(int idx)
           
 float getBounceVel()
           
 float getBounceVel(int idx)
           
 float getDepth()
           
 float getDepth(int idx)
           
 void getFdir1(float[] fdir1)
           
 void getFdir1(float[] fdir1, int idx)
           
 long getGeomID1()
          Returns the native address of the first Geom object involved in this contact.
 long getGeomID1(int idx)
          Returns the native address of the first Geom object involved in this contact.
 long getGeomID2()
          Returns the native address of the second Geom object involved in this contact.
 long getGeomID2(int idx)
          Returns the native address of the second Geom object involved in this contact.
 long getMode()
          Note, if mode = -1 then default surface parameter values are used.
 long getMode(int idx)
          Note, if mode = -1 then default surface parameter values are used.
 float getMotion1()
           
 float getMotion1(int idx)
           
 float getMotion2()
           
 float getMotion2(int idx)
           
 float getMu()
           
 float getMu(int idx)
           
 float getMu2()
           
 float getMu2(int idx)
           
 float[] getNormal()
           
 void getNormal(float[] normal)
           
 void getNormal(float[] normal, int idx)
           
 float[] getNormal(int idx)
           
 void getNormal(org.openmali.vecmath2.Vector3f normal)
           
 void getNormal(org.openmali.vecmath2.Vector3f normal, int idx)
           
 float[] getPosition()
           
 void getPosition(float[] position)
           
 void getPosition(float[] position, int idx)
           
 float[] getPosition(int idx)
           
 void getPosition(org.openmali.vecmath2.Tuple3f position)
           
 void getPosition(org.openmali.vecmath2.Tuple3f position, int idx)
           
 float getSlip1()
           
 float getSlip1(int idx)
           
 float getSlip2()
           
 float getSlip2(int idx)
           
 float getSoftCfm()
           
 float getSoftCfm(int idx)
           
 float getSoftErp()
           
 float getSoftErp(int idx)
           
 void ignoreContact(int idx)
          Ignore contact so it does not affect to simulation.
 void load(int contactCount)
          Bulk load ByteBuffer data to local arrays on a single call.
 void setBodyID1(int id)
           
 void setBodyID1(int id, int idx)
           
 void setBodyID2(int id, int idx)
           
 void setBodyID2(long id)
           
 void setBounce(float bounce)
           
 void setBounce(float bounce, int idx)
           
 void setBounceVel(float bounceVel)
           
 void setBounceVel(float bounceVel, int idx)
           
 void setDepth(float depth)
           
 void setDepth(float depth, int idx)
           
 void setFdir1(float[] fdir1)
           
 void setFdir1(float[] fdir1, int idx)
           
 void setGeomID1(long id)
           
 void setGeomID1(long id, int idx)
           
 void setGeomID2(long id)
           
 void setGeomID2(long id, int idx)
           
 void setMode(int mode)
          Note, if mode = -1 then default surface parameter values are used.
 void setMode(int mode, int idx)
          Note, if mode = -1 then default surface parameter values are used.
 void setMotion1(float motion1)
           
 void setMotion1(float motion1, int idx)
           
 void setMotion2(float motion2)
           
 void setMotion2(float motion2, int idx)
           
 void setMu(float mu)
           
 void setMu(float mu, int idx)
           
 void setMu2(float mu2)
           
 void setMu2(float mu2, int idx)
           
 void setNormal(float[] normal)
           
 void setNormal(float[] normal, int idx)
           
 void setPosition(float[] position)
           
 void setPosition(float[] position, int idx)
           
 void setSlip1(float slip1)
           
 void setSlip1(float slip1, int idx)
           
 void setSlip2(float slip2)
           
 void setSlip2(float slip2, int idx)
           
 void setSoftCfm(float softCfm)
           
 void setSoftCfm(float softCfm, int idx)
           
 void setSoftErp(float softErp)
           
 void setSoftErp(float softErp, int idx)
           
 
Methods inherited from class org.odejava.collision.Contact
geom1EqualTo, geom2EqualTo, getGeom1, getGeom1, getGeom2, getGeom2, getMaxContacts, ignoreContact, nextContact, setFdir1, setFdir1, setIndex, setNormal, setNormal, setPosition, setPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARRAY_SIZE

public static final int ARRAY_SIZE
See Also:
Constant Field Values
Constructor Detail

BulkContact

public BulkContact(LongBuffer longBuf,
                   FloatBuffer floatBuf)
Parameters:
longBuf -
floatBuf -
Method Detail

load

public void load(int contactCount)
Bulk load ByteBuffer data to local arrays on a single call. This is required before you start iterating your contact data. Call e.g. bulkContact.load(collision.getContactCount());


commit

public void commit()
Commit local arrays back to ByteBuffers in a single call. This is required before calling Collision.applyContacts(), if local arrays are changed.


ignoreContact

public void ignoreContact(int idx)
Ignore contact so it does not affect to simulation. Note: if you wish to ignore certain geom <->geom collisions then use categoryBits and collideBits instead, that is a lot faster.

Parameters:
idx - The index of the contact to be ignored

getGeomID1

public long getGeomID1()
Description copied from class: Contact
Returns the native address of the first Geom object involved in this contact.

Overrides:
getGeomID1 in class Contact
Returns:
the native address of the first Geom object involved in this contact.
See Also:
Geom.getNativeAddr(), Geom.getGeomFromNativeAddr(long)

getGeomID1

public long getGeomID1(int idx)
Description copied from class: Contact
Returns the native address of the first Geom object involved in this contact.

Overrides:
getGeomID1 in class Contact
Returns:
the native address of the first Geom object involved in this contact.
See Also:
Geom.getNativeAddr(), Geom.getGeomFromNativeAddr(long)

setGeomID1

public void setGeomID1(long id)
Overrides:
setGeomID1 in class Contact

setGeomID1

public void setGeomID1(long id,
                       int idx)
Overrides:
setGeomID1 in class Contact

getGeomID2

public long getGeomID2()
Description copied from class: Contact
Returns the native address of the second Geom object involved in this contact.

Overrides:
getGeomID2 in class Contact
Returns:
the native address of the second Geom object involved in this contact.
See Also:
Geom.getNativeAddr(), Geom.getGeomFromNativeAddr(long)

getGeomID2

public long getGeomID2(int idx)
Description copied from class: Contact
Returns the native address of the second Geom object involved in this contact.

Overrides:
getGeomID2 in class Contact
Returns:
the native address of the second Geom object involved in this contact.
See Also:
Geom.getNativeAddr(), Geom.getGeomFromNativeAddr(long)

setGeomID2

public void setGeomID2(long id)
Overrides:
setGeomID2 in class Contact

setGeomID2

public void setGeomID2(long id,
                       int idx)
Overrides:
setGeomID2 in class Contact

getBodyID1

public long getBodyID1()
Overrides:
getBodyID1 in class Contact

getBodyID1

public long getBodyID1(int idx)
Overrides:
getBodyID1 in class Contact

setBodyID1

public void setBodyID1(int id)
Overrides:
setBodyID1 in class Contact

setBodyID1

public void setBodyID1(int id,
                       int idx)
Overrides:
setBodyID1 in class Contact

getBodyID2

public long getBodyID2()
Overrides:
getBodyID2 in class Contact

getBodyID2

public long getBodyID2(int idx)
Overrides:
getBodyID2 in class Contact

setBodyID2

public void setBodyID2(long id)
Overrides:
setBodyID2 in class Contact

setBodyID2

public void setBodyID2(int id,
                       int idx)
Overrides:
setBodyID2 in class Contact

getMode

public long getMode()
Note, if mode = -1 then default surface parameter values are used. You can set default surface parameters through Collision class.

Overrides:
getMode in class Contact
Returns:
mode of surface contact

getMode

public long getMode(int idx)
Note, if mode = -1 then default surface parameter values are used. You can set default surface parameters through Collision class.

Overrides:
getMode in class Contact
Returns:
mode of surface contact

setMode

public void setMode(int mode)
Note, if mode = -1 then default surface parameter values are used. You can set default surface parameters through Collision class.

Overrides:
setMode in class Contact
Parameters:
mode - of surface contact

setMode

public void setMode(int mode,
                    int idx)
Note, if mode = -1 then default surface parameter values are used. You can set default surface parameters through Collision class.

Overrides:
setMode in class Contact
Parameters:
mode - of surface contact

getPosition

public void getPosition(org.openmali.vecmath2.Tuple3f position)
Overrides:
getPosition in class Contact

getPosition

public void getPosition(org.openmali.vecmath2.Tuple3f position,
                        int idx)
Overrides:
getPosition in class Contact

getPosition

public void getPosition(float[] position)
Overrides:
getPosition in class Contact

getPosition

public void getPosition(float[] position,
                        int idx)
Overrides:
getPosition in class Contact

getPosition

public float[] getPosition()
Overrides:
getPosition in class Contact

getPosition

public float[] getPosition(int idx)
Overrides:
getPosition in class Contact

setPosition

public void setPosition(float[] position)
Overrides:
setPosition in class Contact

setPosition

public void setPosition(float[] position,
                        int idx)
Overrides:
setPosition in class Contact

getNormal

public void getNormal(org.openmali.vecmath2.Vector3f normal)
Overrides:
getNormal in class Contact

getNormal

public void getNormal(org.openmali.vecmath2.Vector3f normal,
                      int idx)
Overrides:
getNormal in class Contact

getNormal

public void getNormal(float[] normal)
Overrides:
getNormal in class Contact

getNormal

public void getNormal(float[] normal,
                      int idx)
Overrides:
getNormal in class Contact

getNormal

public float[] getNormal()
Overrides:
getNormal in class Contact

getNormal

public float[] getNormal(int idx)
Overrides:
getNormal in class Contact

setNormal

public void setNormal(float[] normal)
Overrides:
setNormal in class Contact

setNormal

public void setNormal(float[] normal,
                      int idx)
Overrides:
setNormal in class Contact

getDepth

public float getDepth()
Overrides:
getDepth in class Contact

getDepth

public float getDepth(int idx)
Overrides:
getDepth in class Contact

setDepth

public void setDepth(float depth)
Overrides:
setDepth in class Contact

setDepth

public void setDepth(float depth,
                     int idx)
Overrides:
setDepth in class Contact

getFdir1

public void getFdir1(float[] fdir1)
Overrides:
getFdir1 in class Contact

getFdir1

public void getFdir1(float[] fdir1,
                     int idx)
Overrides:
getFdir1 in class Contact

setFdir1

public void setFdir1(float[] fdir1)
Overrides:
setFdir1 in class Contact

setFdir1

public void setFdir1(float[] fdir1,
                     int idx)
Overrides:
setFdir1 in class Contact

getMu

public float getMu()
Overrides:
getMu in class Contact

getMu

public float getMu(int idx)
Overrides:
getMu in class Contact

setMu

public void setMu(float mu)
Overrides:
setMu in class Contact

setMu

public void setMu(float mu,
                  int idx)
Overrides:
setMu in class Contact

getMu2

public float getMu2()
Overrides:
getMu2 in class Contact

getMu2

public float getMu2(int idx)
Overrides:
getMu2 in class Contact

setMu2

public void setMu2(float mu2)
Overrides:
setMu2 in class Contact

setMu2

public void setMu2(float mu2,
                   int idx)
Overrides:
setMu2 in class Contact

getBounce

public float getBounce()
Overrides:
getBounce in class Contact

getBounce

public float getBounce(int idx)
Overrides:
getBounce in class Contact

setBounce

public void setBounce(float bounce)
Overrides:
setBounce in class Contact

setBounce

public void setBounce(float bounce,
                      int idx)
Overrides:
setBounce in class Contact

getBounceVel

public float getBounceVel()
Overrides:
getBounceVel in class Contact

getBounceVel

public float getBounceVel(int idx)
Overrides:
getBounceVel in class Contact

setBounceVel

public void setBounceVel(float bounceVel)
Overrides:
setBounceVel in class Contact

setBounceVel

public void setBounceVel(float bounceVel,
                         int idx)
Overrides:
setBounceVel in class Contact

getSoftErp

public float getSoftErp()
Overrides:
getSoftErp in class Contact

getSoftErp

public float getSoftErp(int idx)
Overrides:
getSoftErp in class Contact

setSoftErp

public void setSoftErp(float softErp)
Overrides:
setSoftErp in class Contact

setSoftErp

public void setSoftErp(float softErp,
                       int idx)
Overrides:
setSoftErp in class Contact

getSoftCfm

public float getSoftCfm()
Overrides:
getSoftCfm in class Contact

getSoftCfm

public float getSoftCfm(int idx)
Overrides:
getSoftCfm in class Contact

setSoftCfm

public void setSoftCfm(float softCfm)
Overrides:
setSoftCfm in class Contact

setSoftCfm

public void setSoftCfm(float softCfm,
                       int idx)
Overrides:
setSoftCfm in class Contact

getMotion1

public float getMotion1()
Overrides:
getMotion1 in class Contact

getMotion1

public float getMotion1(int idx)
Overrides:
getMotion1 in class Contact

setMotion1

public void setMotion1(float motion1)
Overrides:
setMotion1 in class Contact

setMotion1

public void setMotion1(float motion1,
                       int idx)
Overrides:
setMotion1 in class Contact

getMotion2

public float getMotion2()
Overrides:
getMotion2 in class Contact

getMotion2

public float getMotion2(int idx)
Overrides:
getMotion2 in class Contact

setMotion2

public void setMotion2(float motion2)
Overrides:
setMotion2 in class Contact

setMotion2

public void setMotion2(float motion2,
                       int idx)
Overrides:
setMotion2 in class Contact

getSlip1

public float getSlip1()
Overrides:
getSlip1 in class Contact

getSlip1

public float getSlip1(int idx)
Overrides:
getSlip1 in class Contact

setSlip1

public void setSlip1(float slip1)
Overrides:
setSlip1 in class Contact

setSlip1

public void setSlip1(float slip1,
                     int idx)
Overrides:
setSlip1 in class Contact

getSlip2

public float getSlip2()
Overrides:
getSlip2 in class Contact

getSlip2

public float getSlip2(int idx)
Overrides:
getSlip2 in class Contact

setSlip2

public void setSlip2(float slip2)
Overrides:
setSlip2 in class Contact

setSlip2

public void setSlip2(float slip2,
                     int idx)
Overrides:
setSlip2 in class Contact