mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 16:08:20 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07bf698c2c | |||
| c740204bd5 |
26
pgo/callbackExports.go
Executable file
26
pgo/callbackExports.go
Executable file
@ -0,0 +1,26 @@
|
||||
package pgo
|
||||
|
||||
/*
|
||||
#include "wrap.c"
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
//export goOnContactCallback
|
||||
func goOnContactCallback(p unsafe.Pointer) {
|
||||
contactCallback(ContactPairHeader{cCPH: (*C.struct_CPxContactPairHeader)(p)})
|
||||
}
|
||||
|
||||
//export goOnTriggerCallback
|
||||
func goOnTriggerCallback(p unsafe.Pointer, count uint32) {
|
||||
|
||||
// @PERF
|
||||
triggerPairs := make([]TriggerPair, count)
|
||||
tPairs := unsafe.Slice((*C.struct_CPxTriggerPair)(p), count)
|
||||
|
||||
for i := 0; i < len(triggerPairs); i++ {
|
||||
triggerPairs[i].cTp = &tPairs[i]
|
||||
}
|
||||
|
||||
triggerCallback(triggerPairs)
|
||||
}
|
||||
@ -1,10 +1,18 @@
|
||||
package pgo
|
||||
|
||||
/*
|
||||
#include <stdint.h> // Needed for uint32_t
|
||||
|
||||
void goOnContactCallback_cgo(void* pairHeader)
|
||||
{
|
||||
void goOnContactCallback(void*);
|
||||
goOnContactCallback(pairHeader);
|
||||
}
|
||||
|
||||
void goOnTriggerCallback_cgo(void* triggerPairs, uint32_t count)
|
||||
{
|
||||
void goOnTriggerCallback(void*, uint32_t);
|
||||
goOnTriggerCallback(triggerPairs, count);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
package pgo
|
||||
|
||||
/*
|
||||
#include "wrap.c"
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
//export goOnContactCallback
|
||||
func goOnContactCallback(p unsafe.Pointer) {
|
||||
contactCallback(ContactPairHeader{cCPH: (*C.struct_CPxContactPairHeader)(p)})
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
49
pgo/pgo.go
49
pgo/pgo.go
@ -13,6 +13,7 @@ package pgo
|
||||
|
||||
//simulation event callbacks forward declarations. Actual definitions MUST be in a go different file
|
||||
void goOnContactCallback_cgo(void* pairHeader);
|
||||
void goOnTriggerCallback_cgo(void* triggerPairs, CPxU32 count);
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
@ -24,6 +25,7 @@ import (
|
||||
|
||||
var (
|
||||
contactCallback func(ContactPairHeader) = func(ContactPairHeader) {}
|
||||
triggerCallback func([]TriggerPair) = func([]TriggerPair) {}
|
||||
)
|
||||
|
||||
type Foundation struct {
|
||||
@ -396,11 +398,18 @@ func (sd *SceneDesc) SetCpuDispatcher(cd CpuDispatcher) {
|
||||
C.CPxSceneDesc_set_cpuDispatcher(sd.cSD, cd.cCpuDisp)
|
||||
}
|
||||
|
||||
// SetOnContactCallback sets the GLOBAL contact callback handler. Physx-c currently only supports 1 contact callback handler.
|
||||
// SetOnContactCallback sets the GLOBAL contact callback handler. We currently only supports 1 contact callback handler.
|
||||
// Setting a contact callback handler overrides the previous one. Only the most recent one gets called.
|
||||
func (sd *SceneDesc) SetOnContactCallback(cb func(ContactPairHeader)) {
|
||||
contactCallback = cb
|
||||
C.CPxSceneDesc_set_onContactCallback(sd.cSD, (C.CPxonContactCallback)(unsafe.Pointer(C.goOnContactCallback_cgo)))
|
||||
C.CPxSceneDesc_set_onContactCallback(sd.cSD, (C.CPxOnContactCallback)(unsafe.Pointer(C.goOnContactCallback_cgo)))
|
||||
}
|
||||
|
||||
// SetOnTriggerCallback sets the GLOBAL trigger callback handler. We currently only supports 1 trugger callback handler.
|
||||
// Setting a handler overrides the previous one. Only the most recent one gets called.
|
||||
func (sd *SceneDesc) SetOnTriggerCallback(cb func([]TriggerPair)) {
|
||||
triggerCallback = cb
|
||||
C.CPxSceneDesc_set_onTriggerCallback(sd.cSD, (C.CPxOnTriggerCallback)(unsafe.Pointer(C.goOnTriggerCallback_cgo)))
|
||||
}
|
||||
|
||||
func NewSceneDesc(ts TolerancesScale) SceneDesc {
|
||||
@ -510,6 +519,42 @@ func (cpp *ContactPairPoint) GetInternalFaceIndices() (float32, float32) {
|
||||
return float32(cpp.cCpp.internalFaceIndex0), float32(cpp.cCpp.internalFaceIndex1)
|
||||
}
|
||||
|
||||
type TriggerPair struct {
|
||||
cTp *C.struct_CPxTriggerPair
|
||||
}
|
||||
|
||||
func (tp *TriggerPair) TriggerShape() Shape {
|
||||
return Shape{
|
||||
cShape: tp.cTp.triggerShape,
|
||||
}
|
||||
}
|
||||
|
||||
func (tp *TriggerPair) TriggerActor() RigidActor {
|
||||
return RigidActor{
|
||||
cRa: tp.cTp.triggerActor,
|
||||
}
|
||||
}
|
||||
|
||||
func (tp *TriggerPair) OtherShape() Shape {
|
||||
return Shape{
|
||||
cShape: tp.cTp.otherShape,
|
||||
}
|
||||
}
|
||||
|
||||
func (tp *TriggerPair) OtherActor() RigidActor {
|
||||
return RigidActor{
|
||||
cRa: tp.cTp.otherActor,
|
||||
}
|
||||
}
|
||||
|
||||
func (tp *TriggerPair) Status() PairFlags {
|
||||
return PairFlags(tp.cTp.status)
|
||||
}
|
||||
|
||||
func (tp *TriggerPair) Flags() TriggerPairFlag {
|
||||
return TriggerPairFlag(tp.cTp.flags)
|
||||
}
|
||||
|
||||
type PvdSceneFlag uint32
|
||||
|
||||
const (
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define CPxContactPairHeader_H
|
||||
|
||||
#include "CPxShape.h"
|
||||
#include "CPxPairFlag.h"
|
||||
#include "CPxRigidActor.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -53,222 +54,6 @@ extern "C" {
|
||||
CPxContactPairFlag_eINTERNAL_CONTACTS_ARE_FLIPPED = (1 << 5)
|
||||
};
|
||||
|
||||
enum CPxPairFlags
|
||||
{
|
||||
/**
|
||||
\brief Process the contacts of this collision pair in the dynamics solver.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
*/
|
||||
CPxPairFlags_eSOLVE_CONTACT = (1 << 0),
|
||||
|
||||
/**
|
||||
\brief Call contact modification callback for this collision pair
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
@see PxContactModifyCallback
|
||||
*/
|
||||
CPxPairFlags_eMODIFY_CONTACTS = (1 << 1),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback or trigger callback when this collision pair starts to be in contact.
|
||||
|
||||
If one of the two collision objects is a trigger shape (see #PxShapeFlag::eTRIGGER_SHAPE)
|
||||
then the trigger callback will get called as soon as the other object enters the trigger volume.
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called when the actors of this collision pair start to be in contact.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_TOUCH_FOUND = (1 << 2),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback while this collision pair is in contact
|
||||
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called while the actors of this collision pair are in contact.
|
||||
|
||||
\note Triggers do not support this event. Persistent trigger contacts need to be tracked separately by observing eNOTIFY_TOUCH_FOUND/eNOTIFY_TOUCH_LOST events.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note No report will get sent if the objects in contact are sleeping.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
\note If this flag gets enabled while a pair is in touch already, there will be no eNOTIFY_TOUCH_PERSISTS events until the pair loses and regains touch.
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_TOUCH_PERSISTS = (1 << 3),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback or trigger callback when this collision pair stops to be in contact
|
||||
|
||||
If one of the two collision objects is a trigger shape (see #PxShapeFlag::eTRIGGER_SHAPE)
|
||||
then the trigger callback will get called as soon as the other object leaves the trigger volume.
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called when the actors of this collision pair stop to be in contact.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note This event will also get triggered if one of the colliding objects gets deleted.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_TOUCH_LOST = (1 << 4),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when this collision pair is in contact during CCD passes.
|
||||
|
||||
If CCD with multiple passes is enabled, then a fast moving object might bounce on and off the same
|
||||
object multiple times. Hence, the same pair might be in contact multiple times during a simulation step.
|
||||
This flag will make sure that all the detected collision during CCD will get reported. For performance
|
||||
reasons, the system can not always tell whether the contact pair lost touch in one of the previous CCD
|
||||
passes and thus can also not always tell whether the contact is new or has persisted. eNOTIFY_TOUCH_CCD
|
||||
just reports when the two collision objects were detected as being in contact during a CCD pass.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Trigger shapes are not supported.
|
||||
|
||||
\note Only takes effect if eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_TOUCH_CCD = (1 << 5),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair exceeds one of the actor-defined force thresholds.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_THRESHOLD_FORCE_FOUND = (1 << 6),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair continues to exceed one of the actor-defined force thresholds.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note If a pair gets re-filtered and this flag has previously been disabled, then the report will not get fired in the same frame even if the force threshold has been reached in the
|
||||
previous one (unless #eNOTIFY_THRESHOLD_FORCE_FOUND has been set in the previous frame).
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_THRESHOLD_FORCE_PERSISTS = (1 << 7),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair falls below one of the actor-defined force thresholds (includes the case where this collision pair stops being in contact).
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note If a pair gets re-filtered and this flag has previously been disabled, then the report will not get fired in the same frame even if the force threshold has been reached in the
|
||||
previous one (unless #eNOTIFY_THRESHOLD_FORCE_FOUND or #eNOTIFY_THRESHOLD_FORCE_PERSISTS has been set in the previous frame).
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_THRESHOLD_FORCE_LOST = (1 << 8),
|
||||
|
||||
/**
|
||||
\brief Provide contact points in contact reports for this collision pair.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies and if used in combination with the flags eNOTIFY_TOUCH_... or eNOTIFY_THRESHOLD_FORCE_...
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxContactPair PxContactPair.extractContacts()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_CONTACT_POINTS = (1 << 9),
|
||||
|
||||
/**
|
||||
\brief This flag is used to indicate whether this pair generates discrete collision detection contacts.
|
||||
|
||||
\note Contacts are only responded to if eSOLVE_CONTACT is enabled.
|
||||
*/
|
||||
CPxPairFlags_eDETECT_DISCRETE_CONTACT = (1 << 10),
|
||||
|
||||
/**
|
||||
\brief This flag is used to indicate whether this pair generates CCD contacts.
|
||||
|
||||
\note The contacts will only be responded to if eSOLVE_CONTACT is enabled on this pair.
|
||||
\note The scene must have PxSceneFlag::eENABLE_CCD enabled to use this feature.
|
||||
\note Non-static bodies of the pair should have PxRigidBodyFlag::eENABLE_CCD specified for this feature to work correctly.
|
||||
\note This flag is not supported with trigger shapes. However, CCD trigger events can be emulated using non-trigger shapes
|
||||
and requesting eNOTIFY_TOUCH_FOUND and eNOTIFY_TOUCH_LOST and not raising eSOLVE_CONTACT on the pair.
|
||||
|
||||
@see PxRigidBodyFlag::eENABLE_CCD
|
||||
@see PxSceneFlag::eENABLE_CCD
|
||||
*/
|
||||
CPxPairFlags_eDETECT_CCD_CONTACT = (1 << 11),
|
||||
|
||||
/**
|
||||
\brief Provide pre solver velocities in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the velocities of the rigid bodies before contacts have been solved
|
||||
will be provided in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
\note Usually it is not necessary to request these velocities as they will be available by querying the velocity from the provided
|
||||
PxRigidActor object directly. However, it might be the case that the velocity of a rigid body gets set while the simulation is running
|
||||
in which case the PxRigidActor would return this new velocity in the contact report callback and not the velocity the simulation used.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairVelocity, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
CPxPairFlags_ePRE_SOLVER_VELOCITY = (1 << 12),
|
||||
|
||||
/**
|
||||
\brief Provide post solver velocities in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the velocities of the rigid bodies after contacts have been solved
|
||||
will be provided in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairVelocity, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
CPxPairFlags_ePOST_SOLVER_VELOCITY = (1 << 13),
|
||||
|
||||
/**
|
||||
\brief Provide rigid body poses in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the rigid body poses at the contact event will be provided
|
||||
in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
\note Usually it is not necessary to request these poses as they will be available by querying the pose from the provided
|
||||
PxRigidActor object directly. However, it might be the case that the pose of a rigid body gets set while the simulation is running
|
||||
in which case the PxRigidActor would return this new pose in the contact report callback and not the pose the simulation used.
|
||||
Another use case is related to CCD with multiple passes enabled, A fast moving object might bounce on and off the same
|
||||
object multiple times. This flag can be used to request the rigid body poses at the time of impact for each such collision event.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairPose, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
CPxPairFlags_eCONTACT_EVENT_POSE = (1 << 14),
|
||||
|
||||
CPxPairFlags_eNEXT_FREE = (1 << 15), //!< For internal use only.
|
||||
|
||||
/**
|
||||
\brief Provided default flag to do simple contact processing for this collision pair.
|
||||
*/
|
||||
CPxPairFlags_eCONTACT_DEFAULT = CPxPairFlags_eSOLVE_CONTACT | CPxPairFlags_eDETECT_DISCRETE_CONTACT,
|
||||
|
||||
/**
|
||||
\brief Provided default flag to get commonly used trigger behavior for this collision pair.
|
||||
*/
|
||||
CPxPairFlags_eTRIGGER_DEFAULT = CPxPairFlags_eNOTIFY_TOUCH_FOUND | CPxPairFlags_eNOTIFY_TOUCH_LOST | CPxPairFlags_eDETECT_DISCRETE_CONTACT
|
||||
};
|
||||
|
||||
struct CPxContactPairPoint
|
||||
{
|
||||
/**
|
||||
@ -314,7 +99,7 @@ extern "C" {
|
||||
CPxU8 patchCount;
|
||||
CPxU16 contactStreamSize;
|
||||
|
||||
CENUM CPxPairFlags events;
|
||||
CENUM CPxPairFlag events;
|
||||
CENUM CPxContactPairFlag flags;
|
||||
|
||||
CSTRUCT CPxContactPairPoint* extractedContactPoints;
|
||||
@ -343,4 +128,4 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // !1
|
||||
#endif
|
||||
228
pgo/physx-c/CPxPairFlag.h
Executable file
228
pgo/physx-c/CPxPairFlag.h
Executable file
@ -0,0 +1,228 @@
|
||||
#ifndef CPxPairFlag_H
|
||||
#define CPxPairFlag_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum CPxPairFlag
|
||||
{
|
||||
/**
|
||||
\brief Process the contacts of this collision pair in the dynamics solver.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
*/
|
||||
CPxPairFlags_eSOLVE_CONTACT = (1 << 0),
|
||||
|
||||
/**
|
||||
\brief Call contact modification callback for this collision pair
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
@see PxContactModifyCallback
|
||||
*/
|
||||
CPxPairFlags_eMODIFY_CONTACTS = (1 << 1),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback or trigger callback when this collision pair starts to be in contact.
|
||||
|
||||
If one of the two collision objects is a trigger shape (see #PxShapeFlag::eTRIGGER_SHAPE)
|
||||
then the trigger callback will get called as soon as the other object enters the trigger volume.
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called when the actors of this collision pair start to be in contact.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_TOUCH_FOUND = (1 << 2),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback while this collision pair is in contact
|
||||
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called while the actors of this collision pair are in contact.
|
||||
|
||||
\note Triggers do not support this event. Persistent trigger contacts need to be tracked separately by observing eNOTIFY_TOUCH_FOUND/eNOTIFY_TOUCH_LOST events.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note No report will get sent if the objects in contact are sleeping.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
\note If this flag gets enabled while a pair is in touch already, there will be no eNOTIFY_TOUCH_PERSISTS events until the pair loses and regains touch.
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_TOUCH_PERSISTS = (1 << 3),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback or trigger callback when this collision pair stops to be in contact
|
||||
|
||||
If one of the two collision objects is a trigger shape (see #PxShapeFlag::eTRIGGER_SHAPE)
|
||||
then the trigger callback will get called as soon as the other object leaves the trigger volume.
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called when the actors of this collision pair stop to be in contact.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note This event will also get triggered if one of the colliding objects gets deleted.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_TOUCH_LOST = (1 << 4),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when this collision pair is in contact during CCD passes.
|
||||
|
||||
If CCD with multiple passes is enabled, then a fast moving object might bounce on and off the same
|
||||
object multiple times. Hence, the same pair might be in contact multiple times during a simulation step.
|
||||
This flag will make sure that all the detected collision during CCD will get reported. For performance
|
||||
reasons, the system can not always tell whether the contact pair lost touch in one of the previous CCD
|
||||
passes and thus can also not always tell whether the contact is new or has persisted. eNOTIFY_TOUCH_CCD
|
||||
just reports when the two collision objects were detected as being in contact during a CCD pass.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Trigger shapes are not supported.
|
||||
|
||||
\note Only takes effect if eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_TOUCH_CCD = (1 << 5),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair exceeds one of the actor-defined force thresholds.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_THRESHOLD_FORCE_FOUND = (1 << 6),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair continues to exceed one of the actor-defined force thresholds.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note If a pair gets re-filtered and this flag has previously been disabled, then the report will not get fired in the same frame even if the force threshold has been reached in the
|
||||
previous one (unless #eNOTIFY_THRESHOLD_FORCE_FOUND has been set in the previous frame).
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_THRESHOLD_FORCE_PERSISTS = (1 << 7),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair falls below one of the actor-defined force thresholds (includes the case where this collision pair stops being in contact).
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note If a pair gets re-filtered and this flag has previously been disabled, then the report will not get fired in the same frame even if the force threshold has been reached in the
|
||||
previous one (unless #eNOTIFY_THRESHOLD_FORCE_FOUND or #eNOTIFY_THRESHOLD_FORCE_PERSISTS has been set in the previous frame).
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_THRESHOLD_FORCE_LOST = (1 << 8),
|
||||
|
||||
/**
|
||||
\brief Provide contact points in contact reports for this collision pair.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies and if used in combination with the flags eNOTIFY_TOUCH_... or eNOTIFY_THRESHOLD_FORCE_...
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxContactPair PxContactPair.extractContacts()
|
||||
*/
|
||||
CPxPairFlags_eNOTIFY_CONTACT_POINTS = (1 << 9),
|
||||
|
||||
/**
|
||||
\brief This flag is used to indicate whether this pair generates discrete collision detection contacts.
|
||||
|
||||
\note Contacts are only responded to if eSOLVE_CONTACT is enabled.
|
||||
*/
|
||||
CPxPairFlags_eDETECT_DISCRETE_CONTACT = (1 << 10),
|
||||
|
||||
/**
|
||||
\brief This flag is used to indicate whether this pair generates CCD contacts.
|
||||
|
||||
\note The contacts will only be responded to if eSOLVE_CONTACT is enabled on this pair.
|
||||
\note The scene must have PxSceneFlag::eENABLE_CCD enabled to use this feature.
|
||||
\note Non-static bodies of the pair should have PxRigidBodyFlag::eENABLE_CCD specified for this feature to work correctly.
|
||||
\note This flag is not supported with trigger shapes. However, CCD trigger events can be emulated using non-trigger shapes
|
||||
and requesting eNOTIFY_TOUCH_FOUND and eNOTIFY_TOUCH_LOST and not raising eSOLVE_CONTACT on the pair.
|
||||
|
||||
@see PxRigidBodyFlag::eENABLE_CCD
|
||||
@see PxSceneFlag::eENABLE_CCD
|
||||
*/
|
||||
CPxPairFlags_eDETECT_CCD_CONTACT = (1 << 11),
|
||||
|
||||
/**
|
||||
\brief Provide pre solver velocities in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the velocities of the rigid bodies before contacts have been solved
|
||||
will be provided in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
\note Usually it is not necessary to request these velocities as they will be available by querying the velocity from the provided
|
||||
PxRigidActor object directly. However, it might be the case that the velocity of a rigid body gets set while the simulation is running
|
||||
in which case the PxRigidActor would return this new velocity in the contact report callback and not the velocity the simulation used.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairVelocity, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
CPxPairFlags_ePRE_SOLVER_VELOCITY = (1 << 12),
|
||||
|
||||
/**
|
||||
\brief Provide post solver velocities in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the velocities of the rigid bodies after contacts have been solved
|
||||
will be provided in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairVelocity, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
CPxPairFlags_ePOST_SOLVER_VELOCITY = (1 << 13),
|
||||
|
||||
/**
|
||||
\brief Provide rigid body poses in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the rigid body poses at the contact event will be provided
|
||||
in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
\note Usually it is not necessary to request these poses as they will be available by querying the pose from the provided
|
||||
PxRigidActor object directly. However, it might be the case that the pose of a rigid body gets set while the simulation is running
|
||||
in which case the PxRigidActor would return this new pose in the contact report callback and not the pose the simulation used.
|
||||
Another use case is related to CCD with multiple passes enabled, A fast moving object might bounce on and off the same
|
||||
object multiple times. This flag can be used to request the rigid body poses at the time of impact for each such collision event.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairPose, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
CPxPairFlags_eCONTACT_EVENT_POSE = (1 << 14),
|
||||
|
||||
CPxPairFlags_eNEXT_FREE = (1 << 15), //!< For internal use only.
|
||||
|
||||
/**
|
||||
\brief Provided default flag to do simple contact processing for this collision pair.
|
||||
*/
|
||||
CPxPairFlags_eCONTACT_DEFAULT = CPxPairFlags_eSOLVE_CONTACT | CPxPairFlags_eDETECT_DISCRETE_CONTACT,
|
||||
|
||||
/**
|
||||
\brief Provided default flag to get commonly used trigger behavior for this collision pair.
|
||||
*/
|
||||
CPxPairFlags_eTRIGGER_DEFAULT = CPxPairFlags_eNOTIFY_TOUCH_FOUND | CPxPairFlags_eNOTIFY_TOUCH_LOST | CPxPairFlags_eDETECT_DISCRETE_CONTACT
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -4,19 +4,18 @@
|
||||
#include "CPxFilterData.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct CPxRigidActor
|
||||
{
|
||||
void *obj;
|
||||
void* obj;
|
||||
};
|
||||
|
||||
// Sets the CPxFilterData on all the shapes of the actor.
|
||||
//Sets the CPxFilterData on all the shapes of the actor.
|
||||
CPxAPI void CPxRigidActor_setSimFilterData(CSTRUCT CPxRigidActor cra, CSTRUCT CPxFilterData cfd);
|
||||
CPxAPI void CPxRigidActor_set_userData(CSTRUCT CPxRigidActor cra, void *userData);
|
||||
CPxAPI void *CPxRigidActor_get_userData(CSTRUCT CPxRigidActor cra);
|
||||
CPxAPI void CPxRigidActor_set_userData(CSTRUCT CPxRigidActor cra, void* userData);
|
||||
CPxAPI void* CPxRigidActor_get_userData(CSTRUCT CPxRigidActor cra);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -30,7 +30,17 @@ extern "C" {
|
||||
CPxAPI CPxReal CPxRigidDynamic_getAngularDamping(CSTRUCT CPxRigidDynamic crd);
|
||||
|
||||
CPxAPI CSTRUCT CPxVec3 CPxRigidDynamic_getLinearVelocity(CSTRUCT CPxRigidDynamic crd);
|
||||
CPxAPI void CPxRigidDynamic_setLinearVelocity(CSTRUCT CPxRigidDynamic crd, CSTRUCT CPxVec3* velocity, bool autoAwake);
|
||||
|
||||
CPxAPI CPxReal CPxRigidDynamic_getMaxLinearVelocity(CSTRUCT CPxRigidDynamic crd);
|
||||
CPxAPI void CPxRigidDynamic_setMaxLinearVelocity(CSTRUCT CPxRigidDynamic crd, CPxReal maxLinearVelocity);
|
||||
|
||||
|
||||
CPxAPI CSTRUCT CPxVec3 CPxRigidDynamic_getAngularVelocity(CSTRUCT CPxRigidDynamic crd);
|
||||
CPxAPI void CPxRigidDynamic_setAngularVelocity(CSTRUCT CPxRigidDynamic crd, CSTRUCT CPxVec3* velocity, bool autoAwake);
|
||||
|
||||
CPxAPI CPxReal CPxRigidDynamic_getMaxAngularVelocity(CSTRUCT CPxRigidDynamic crd);
|
||||
CPxAPI void CPxRigidDynamic_setMaxAngularVelocity(CSTRUCT CPxRigidDynamic crd, CPxReal maxAngularVelocity);
|
||||
|
||||
CPxAPI void CPxRigidDynamic_setMass(CSTRUCT CPxRigidDynamic crd, CPxReal mass);
|
||||
CPxAPI CPxReal CPxRigidDynamic_getMass(CSTRUCT CPxRigidDynamic crd);
|
||||
|
||||
@ -13,7 +13,8 @@ extern "C" {
|
||||
void* obj;
|
||||
};
|
||||
|
||||
typedef void (*CPxonContactCallback)(void* pairHeader);
|
||||
typedef void (*CPxOnContactCallback)(void* pairHeader);
|
||||
typedef void (*CPxOnTriggerCallback)(void* triggerPairs, CPxU32 count);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a SceneDesc with a custom filterShader that uses word0/word1 as groups shapes can belong to, word2 as a mask on word0, and word3 as a mask on word1.
|
||||
@ -25,12 +26,20 @@ extern "C" {
|
||||
CPxAPI void CPxSceneDesc_set_cpuDispatcher(CSTRUCT CPxSceneDesc, CSTRUCT CPxCpuDispatcher);
|
||||
|
||||
|
||||
//CPxSceneDesc_set_onContactCallback sets the contact callback handler of the given scene descriptor.
|
||||
//The callback is sent an object of type 'CPxContactPairHeader*'. This object is only valid for the duration of the callback handler.
|
||||
//Therefore, the callback handler MUST copy data it wishes to keep for longer than the lifetime of the callback handler, as the memory it was handed might be reused/freed.
|
||||
// CPxSceneDesc_set_onContactCallback sets the on-contact callback handler of the given scene descriptor.
|
||||
// The callback is sent an object of type 'CPxContactPairHeader*'. This object is only valid for the duration of the callback handler.
|
||||
// Therefore, the callback handler MUST copy data it wishes to keep for longer than the lifetime of the callback handler, as the memory it was handed might be reused/freed.
|
||||
//
|
||||
//NOTE: This function assumes you are using the default physx-c callback handler. Do NOT use this function if you set 'sceneDesc->simulationEventCallback' with your own custom implementation.
|
||||
CPxAPI void CPxSceneDesc_set_onContactCallback(CSTRUCT CPxSceneDesc, CPxonContactCallback cb);
|
||||
// NOTE: This function assumes you are using the default physx-c callback handler. Do NOT use this function if you set 'sceneDesc->simulationEventCallback' with your own custom implementation.
|
||||
CPxAPI void CPxSceneDesc_set_onContactCallback(CSTRUCT CPxSceneDesc, CPxOnContactCallback cb);
|
||||
|
||||
// CPxSceneDesc_set_onTriggerCallback sets the on-trigger callback handler of the given scene descriptor.
|
||||
// The callback is sent an object of type 'CPxTriggerPairHeader*'. This object is only valid for the duration of the callback handler.
|
||||
// Therefore, the callback handler MUST copy data it wishes to keep for longer than the lifetime of the callback handler, as the memory it was handed might be reused/freed.
|
||||
//
|
||||
// NOTE: This function assumes you are using the default physx-c callback handler. Do NOT use this function if you set 'sceneDesc->simulationEventCallback' with your own custom implementation.
|
||||
CPxAPI void CPxSceneDesc_set_onTriggerCallback(CSTRUCT CPxSceneDesc csd, CPxOnTriggerCallback cb);
|
||||
|
||||
CPxAPI void FreeCPxSceneDesc(CSTRUCT CPxSceneDesc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
27
pgo/physx-c/CPxTriggerPair.h
Executable file
27
pgo/physx-c/CPxTriggerPair.h
Executable file
@ -0,0 +1,27 @@
|
||||
#ifndef CPxTriggerPair_H
|
||||
#define CPxTriggerPair_H
|
||||
|
||||
#include "CPxShape.h"
|
||||
#include "CPxPairFlag.h"
|
||||
#include "CPxRigidActor.h"
|
||||
#include "CPxTriggerPairFlag.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct CPxTriggerPair
|
||||
{
|
||||
CSTRUCT CPxShape triggerShape; //!< The shape that has been marked as a trigger.
|
||||
CSTRUCT CPxRigidActor triggerActor; //!< The actor to which triggerShape is attached
|
||||
CSTRUCT CPxShape otherShape; //!< The shape causing the trigger event. \deprecated (see #PxSimulationEventCallback::onTrigger()) If collision between trigger shapes is enabled, then this member might point to a trigger shape as well.
|
||||
CSTRUCT CPxRigidActor otherActor; //!< The actor to which otherShape is attached
|
||||
CENUM CPxPairFlag status; //!< Type of trigger event (eNOTIFY_TOUCH_FOUND or eNOTIFY_TOUCH_LOST). eNOTIFY_TOUCH_PERSISTS events are not supported.
|
||||
CENUM CPxTriggerPairFlag flags; //!< Additional information on the pair (see #PxTriggerPairFlag)
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
20
pgo/physx-c/CPxTriggerPairFlag.h
Executable file
20
pgo/physx-c/CPxTriggerPairFlag.h
Executable file
@ -0,0 +1,20 @@
|
||||
#ifndef CPxTriggerPairFlag_H
|
||||
#define CPxTriggerPairFlag_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
enum CPxTriggerPairFlag
|
||||
{
|
||||
eREMOVED_SHAPE_TRIGGER = (1 << 0), //!< The trigger shape has been removed from the actor/scene.
|
||||
eREMOVED_SHAPE_OTHER = (1 << 1), //!< The shape causing the trigger event has been removed from the actor/scene.
|
||||
eNEXT_FREE = (1 << 2) //!< For internal use only.
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -29,14 +29,14 @@ func (rd *RigidDynamic) SetLinearDamping(damping float32) {
|
||||
C.CPxRigidDynamic_setLinearDamping(rd.cRd, C.float(damping))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) SetAngularDamping(damping float32) {
|
||||
C.CPxRigidDynamic_setAngularDamping(rd.cRd, C.float(damping))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) GetLinearDamping() float32 {
|
||||
return float32(C.CPxRigidDynamic_getLinearDamping(rd.cRd))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) SetAngularDamping(damping float32) {
|
||||
C.CPxRigidDynamic_setAngularDamping(rd.cRd, C.float(damping))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) GetAngularDamping() float32 {
|
||||
return float32(C.CPxRigidDynamic_getAngularDamping(rd.cRd))
|
||||
}
|
||||
@ -47,12 +47,36 @@ func (rd *RigidDynamic) GetLinearVelocity() Vec3 {
|
||||
}
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) SetLinearVelocity(vel *Vec3, autoWake bool) {
|
||||
C.CPxRigidDynamic_setLinearVelocity(rd.cRd, &vel.cV, C._Bool(autoWake))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) GetAngularVelocity() Vec3 {
|
||||
return Vec3{
|
||||
cV: C.CPxRigidDynamic_getAngularVelocity(rd.cRd),
|
||||
}
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) SetAngularVelocity(vel *Vec3, autoWake bool) {
|
||||
C.CPxRigidDynamic_setAngularVelocity(rd.cRd, &vel.cV, C._Bool(autoWake))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) GetMaxLinearVelocity() float32 {
|
||||
return float32(C.CPxRigidDynamic_getMaxLinearVelocity(rd.cRd))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) SetMaxLinearVelocity(vel float32) {
|
||||
C.CPxRigidDynamic_setMaxLinearVelocity(rd.cRd, C.float(vel))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) GetMaxAngularVelocity() float32 {
|
||||
return float32(C.CPxRigidDynamic_getMaxAngularVelocity(rd.cRd))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) SetMaxAngularVelocity(vel float32) {
|
||||
C.CPxRigidDynamic_setMaxAngularVelocity(rd.cRd, C.float(vel))
|
||||
}
|
||||
|
||||
func (rd *RigidDynamic) SetMass(mass float32) {
|
||||
C.CPxRigidDynamic_setMass(rd.cRd, C.float(mass))
|
||||
}
|
||||
|
||||
9
pgo/triggerPairFlag.go
Executable file
9
pgo/triggerPairFlag.go
Executable file
@ -0,0 +1,9 @@
|
||||
package pgo
|
||||
|
||||
type TriggerPairFlag uint32
|
||||
|
||||
const (
|
||||
TriggerPairFlag_eREMOVED_SHAPE_TRIGGER TriggerPairFlag = (1 << 0) //!< The trigger shape has been removed from the actor/scene.
|
||||
TriggerPairFlag_eREMOVED_SHAPE_OTHER TriggerPairFlag = (1 << 1) //!< The shape causing the trigger event has been removed from the actor/scene.
|
||||
TriggerPairFlag_eNEXT_FREE TriggerPairFlag = (1 << 2) //!< For internal use only.
|
||||
)
|
||||
@ -39,4 +39,5 @@
|
||||
|
||||
#include <CPxSimpleFactory.h>
|
||||
|
||||
#include <CPxTriggerPair.h>
|
||||
#include <CPxContactPairHeader.h>
|
||||
Reference in New Issue
Block a user