mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 07:58:20 +00:00
Full onContact data+inlining
This commit is contained in:
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
||||
module github.com/bloeys/physx-go
|
||||
|
||||
go 1.17
|
||||
|
||||
require github.com/bloeys/gglm v0.3.1 // indirect
|
||||
|
||||
2
go.sum
Executable file
2
go.sum
Executable file
@ -0,0 +1,2 @@
|
||||
github.com/bloeys/gglm v0.3.1 h1:Sy9upW7SBsBfDXrSmEhid3aQ+7J7itej+upwcxOnPMQ=
|
||||
github.com/bloeys/gglm v0.3.1/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
|
||||
28
main.go
28
main.go
@ -1,13 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/bloeys/physx-go/pgo"
|
||||
)
|
||||
|
||||
func contactHandler(cph pgo.ContactPairHeader) {
|
||||
|
||||
pairs := cph.GetPairs()
|
||||
for i := 0; i < len(pairs); i++ {
|
||||
|
||||
points := pairs[i].GetContactPoints()
|
||||
for j := 0; j < pairs[i].GetContactPointCount(); j++ {
|
||||
pos := points[j].GetPos()
|
||||
println("Contact at pos:", pos.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
f := pgo.CreateFoundation()
|
||||
println("foundation:", f)
|
||||
@ -26,7 +35,7 @@ func main() {
|
||||
sd := pgo.NewSceneDesc(ts)
|
||||
sd.SetGravity(pgo.NewVec3(0, -9.8, 0))
|
||||
sd.SetCpuDispatcher(pgo.DefaultCpuDispatcherCreate(2, 0).ToCpuDispatcher())
|
||||
sd.SetOnContactCallback()
|
||||
sd.SetOnContactCallback(contactHandler)
|
||||
|
||||
s := p.CreateScene(sd)
|
||||
println("Scene:", s)
|
||||
@ -115,17 +124,16 @@ func main() {
|
||||
println("Capsule linear damping B:", dynCapsule.GetLinearDamping())
|
||||
|
||||
//Run simulation
|
||||
r := bufio.NewReader(os.Stdin)
|
||||
// r := bufio.NewReader(os.Stdin)
|
||||
s.SetScratchBuffer(4)
|
||||
for {
|
||||
s.Collide(1 / 60.0)
|
||||
s.Collide(1 / 50.0)
|
||||
s.FetchCollision(true)
|
||||
s.Advance()
|
||||
s.FetchResults(true)
|
||||
|
||||
rHit, _ := s.Raycast(pgo.NewVec3(0, 0, 0), pgo.NewVec3(0, 1, 0), 9)
|
||||
fmt.Printf("\nRaycast hit: %v\n", rHit)
|
||||
|
||||
s.Raycast(pgo.NewVec3(0, 0, 0), pgo.NewVec3(0, 1, 0), 9)
|
||||
// fmt.Printf("\nRaycast hit: %v\n", rHit)
|
||||
// println("Press enter...")
|
||||
// r.ReadBytes('\n')
|
||||
}
|
||||
|
||||
47
pgo/contactPairFlag.go
Executable file
47
pgo/contactPairFlag.go
Executable file
@ -0,0 +1,47 @@
|
||||
package pgo
|
||||
|
||||
type ContactPairFlag uint16
|
||||
|
||||
const (
|
||||
|
||||
/**
|
||||
\brief The shape with index 0 has been removed from the actor/scene.
|
||||
*/
|
||||
ContactPairFlag_eREMOVED_SHAPE_0 ContactPairFlag = (1 << 0)
|
||||
|
||||
/**
|
||||
\brief The shape with index 1 has been removed from the actor/scene.
|
||||
*/
|
||||
ContactPairFlag_eREMOVED_SHAPE_1 ContactPairFlag = (1 << 1)
|
||||
|
||||
/**
|
||||
\brief First actor pair contact.
|
||||
|
||||
The provided shape pair marks the first contact between the two actors, no other shape pair has been touching prior to the current simulation frame.
|
||||
|
||||
\note: This info is only available if #PxPairFlag::eNOTIFY_TOUCH_FOUND has been declared for the pair.
|
||||
*/
|
||||
ContactPairFlag_eACTOR_PAIR_HAS_FIRST_TOUCH ContactPairFlag = (1 << 2)
|
||||
|
||||
/**
|
||||
\brief All contact between the actor pair was lost.
|
||||
|
||||
All contact between the two actors has been lost, no shape pairs remain touching after the current simulation frame.
|
||||
*/
|
||||
ContactPairFlag_eACTOR_PAIR_LOST_TOUCH ContactPairFlag = (1 << 3)
|
||||
|
||||
/**
|
||||
\brief Internal flag, used by #PxContactPair.extractContacts()
|
||||
|
||||
The applied contact impulses are provided for every contact point.
|
||||
This is the case if #PxPairFlag::eSOLVE_CONTACT has been set for the pair.
|
||||
*/
|
||||
ContactPairFlag_eINTERNAL_HAS_IMPULSES ContactPairFlag = (1 << 4)
|
||||
|
||||
/**
|
||||
\brief Internal flag, used by #PxContactPair.extractContacts()
|
||||
|
||||
The provided contact point information is flipped with regards to the shapes of the contact pair. This mainly concerns the order of the internal triangle indices.
|
||||
*/
|
||||
ContactPairFlag_eINTERNAL_CONTACTS_ARE_FLIPPED ContactPairFlag = (1 << 5)
|
||||
)
|
||||
8
pgo/contactPairHeaderFlag.go
Executable file
8
pgo/contactPairHeaderFlag.go
Executable file
@ -0,0 +1,8 @@
|
||||
package pgo
|
||||
|
||||
type ContactPairHeaderFlag uint16
|
||||
|
||||
const (
|
||||
ContactPairHeaderFlag_eREMOVED_ACTOR_0 ContactPairHeaderFlag = (1 << 0) //!< The actor with index 0 has been removed from the scene.
|
||||
ContactPairHeaderFlag_eREMOVED_ACTOR_1 ContactPairHeaderFlag = (1 << 1) //!< The actor with index 1 has been removed from the scene.
|
||||
)
|
||||
12
pgo/goContactCallbackExport.go
Executable file
12
pgo/goContactCallbackExport.go
Executable file
@ -0,0 +1,12 @@
|
||||
package pgo
|
||||
|
||||
/*
|
||||
#include "wrap.c"
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
//export goOnContactCallback
|
||||
func goOnContactCallback(p unsafe.Pointer) {
|
||||
contactCallback(ContactPairHeader{cCPH: (*C.struct_CPxContactPairHeader)(p)})
|
||||
}
|
||||
24
pgo/hitFlag.go
Executable file
24
pgo/hitFlag.go
Executable file
@ -0,0 +1,24 @@
|
||||
package pgo
|
||||
|
||||
type HitFlag uint16
|
||||
|
||||
const (
|
||||
HitFlag_ePOSITION HitFlag = (1 << 0) //!< "position" member of #PxQueryHit is valid
|
||||
HitFlag_eNORMAL HitFlag = (1 << 1) //!< "normal" member of #PxQueryHit is valid
|
||||
HitFlag_eUV HitFlag = (1 << 3) //!< "u" and "v" barycentric coordinates of #PxQueryHit are valid. Not applicable to sweep queries.
|
||||
HitFlag_eASSUME_NO_INITIAL_OVERLAP HitFlag = (1 << 4) //!< Performance hint flag for sweeps when it is known upfront there's no initial overlap.
|
||||
//!< NOTE: using this flag may cause undefined results if shapes are initially overlapping.
|
||||
HitFlag_eMESH_MULTIPLE HitFlag = (1 << 5) //!< Report all hits for meshes rather than just the first. Not applicable to sweep queries.
|
||||
HitFlag_eMESH_ANY HitFlag = (1 << 6) //!< Report any first hit for meshes. If neither eMESH_MULTIPLE nor eMESH_ANY is specified,
|
||||
//!< a single closest hit will be reported for meshes.
|
||||
HitFlag_eMESH_BOTH_SIDES HitFlag = (1 << 7) //!< Report hits with back faces of mesh triangles. Also report hits for raycast
|
||||
//!< originating on mesh surface and facing away from the surface normal. Not applicable to sweep queries.
|
||||
//!< Please refer to the user guide for heightfield-specific differences.
|
||||
HitFlag_ePRECISE_SWEEP HitFlag = (1 << 8) //!< Use more accurate but slower narrow phase sweep tests.
|
||||
//!< May provide better compatibility with PhysX 3.2 sweep behavior.
|
||||
HitFlag_eMTD HitFlag = (1 << 9) //!< Report the minimum translation depth, normal and contact point.
|
||||
HitFlag_eFACE_INDEX HitFlag = (1 << 10) //!< "face index" member of #PxQueryHit is valid
|
||||
HitFlag_eDEFAULT HitFlag = HitFlag_ePOSITION | HitFlag_eNORMAL | HitFlag_eFACE_INDEX
|
||||
/** \brief Only this subset of flags can be modified by pre-filter. Other modifications will be discarded. */
|
||||
HitFlag_eMODIFIABLE_FLAGS HitFlag = HitFlag_eMESH_MULTIPLE | HitFlag_eMESH_BOTH_SIDES | HitFlag_eASSUME_NO_INITIAL_OVERLAP | HitFlag_ePRECISE_SWEEP
|
||||
)
|
||||
Binary file not shown.
170
pgo/pgo.go
170
pgo/pgo.go
@ -11,15 +11,14 @@ package pgo
|
||||
void goOnContactCallback_cgo(void* pairHeader);
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
type PvdInstrumentationFlag uint32
|
||||
"github.com/bloeys/gglm/gglm"
|
||||
)
|
||||
|
||||
const (
|
||||
PvdInstrumentationFlag_eDEBUG PvdInstrumentationFlag = 1 << 0
|
||||
PvdInstrumentationFlag_ePROFILE PvdInstrumentationFlag = 1 << 1
|
||||
PvdInstrumentationFlag_eMEMORY PvdInstrumentationFlag = 1 << 2
|
||||
PvdInstrumentationFlag_eALL PvdInstrumentationFlag = (PvdInstrumentationFlag_eDEBUG | PvdInstrumentationFlag_ePROFILE | PvdInstrumentationFlag_eMEMORY)
|
||||
var (
|
||||
contactCallback func(ContactPairHeader) = func(ContactPairHeader) {}
|
||||
)
|
||||
|
||||
type Foundation struct {
|
||||
@ -79,10 +78,12 @@ type TolerancesScale struct {
|
||||
}
|
||||
|
||||
func NewTolerancesScale(length, speed float32) *TolerancesScale {
|
||||
|
||||
ts := &TolerancesScale{}
|
||||
ts.cTolScale = C.NewCPxTolerancesScale(C.float(length), C.float(speed))
|
||||
return ts
|
||||
return &TolerancesScale{
|
||||
cTolScale: C.struct_CPxTolerancesScale{
|
||||
length: C.float(length),
|
||||
speed: C.float(speed),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type Scene struct {
|
||||
@ -126,11 +127,13 @@ func (s *Scene) SetScratchBuffer(multiplesOf16k uint32) {
|
||||
C.CPxScene_setScratchBuffer(s.cS, C.uint(multiplesOf16k))
|
||||
}
|
||||
|
||||
//bool CPxScene_raycast(CSTRUCT CPxScene* cs, CPxVec3* origin, CPxVec3* unitDir, CPxReal distance, CPxRaycastBuffer* hit)
|
||||
//TODO: Implement
|
||||
func (s *Scene) Raycast(origin, unitDir *Vec3, distance float32) (bool, RaycastBuffer) {
|
||||
|
||||
rb := RaycastBuffer{}
|
||||
ret := C.CPxScene_raycast(s.cS, &origin.cV, &unitDir.cV, C.float(distance), &rb.cRb)
|
||||
// x := unsafe.Slice(rb.cRb.touches, rb.cRb.nbTouches)
|
||||
|
||||
return bool(ret), rb
|
||||
}
|
||||
|
||||
@ -253,7 +256,11 @@ func (v *Vec3) Z() float32 {
|
||||
|
||||
func NewVec3(x, y, z float32) *Vec3 {
|
||||
return &Vec3{
|
||||
cV: C.NewCPxVec3(C.float(x), C.float(y), C.float(z)),
|
||||
cV: C.struct_CPxVec3{
|
||||
x: C.float(x),
|
||||
y: C.float(y),
|
||||
z: C.float(z),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,23 +294,10 @@ func (sd *SceneDesc) SetCpuDispatcher(cd *CpuDispatcher) {
|
||||
C.CPxSceneDesc_set_cpuDispatcher(sd.cSD, cd.cCpuDisp)
|
||||
}
|
||||
|
||||
//export goOnContactCallback
|
||||
func goOnContactCallback(p unsafe.Pointer) {
|
||||
|
||||
cph := (*C.struct_CPxContactPairHeader)(p)
|
||||
pairs := cph.pairs
|
||||
|
||||
if pairs.events == uint32(PairFlags_eNOTIFY_TOUCH_FOUND) {
|
||||
println("touch")
|
||||
} else if pairs.events == uint32(PairFlags_eNOTIFY_TOUCH_PERSISTS) {
|
||||
println("persist")
|
||||
} else if pairs.events == uint32(PairFlags_eNOTIFY_TOUCH_LOST) {
|
||||
println("leave")
|
||||
}
|
||||
}
|
||||
|
||||
func (sd *SceneDesc) SetOnContactCallback() {
|
||||
|
||||
//SetOnContactCallback sets the GLOBAL contact callback handler. Physx-c 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)))
|
||||
}
|
||||
|
||||
@ -313,6 +307,107 @@ func NewSceneDesc(ts *TolerancesScale) *SceneDesc {
|
||||
}
|
||||
}
|
||||
|
||||
type ContactPairHeader struct {
|
||||
cCPH *C.struct_CPxContactPairHeader
|
||||
}
|
||||
|
||||
func (cph *ContactPairHeader) GetRigidActors() [2]RigidActor {
|
||||
return [2]RigidActor{
|
||||
{
|
||||
cRa: cph.cCPH.actors[0],
|
||||
},
|
||||
{
|
||||
cRa: cph.cCPH.actors[1],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (cph *ContactPairHeader) GetFlags() ContactPairHeaderFlag {
|
||||
return ContactPairHeaderFlag(cph.cCPH.flags)
|
||||
}
|
||||
|
||||
func (cph *ContactPairHeader) GetnbPairs() int {
|
||||
return int(cph.cCPH.nbPairs)
|
||||
}
|
||||
|
||||
func (cph *ContactPairHeader) GetPairs() []ContactPair {
|
||||
|
||||
contactPairs := make([]ContactPair, cph.cCPH.nbPairs)
|
||||
cPairs := unsafe.Slice(cph.cCPH.pairs, cph.cCPH.nbPairs)
|
||||
for i := 0; i < len(contactPairs); i++ {
|
||||
contactPairs[i].cCp = &cPairs[i]
|
||||
}
|
||||
|
||||
return contactPairs
|
||||
}
|
||||
|
||||
type ContactPair struct {
|
||||
cCp *C.struct_CPxContactPair
|
||||
}
|
||||
|
||||
func (cp *ContactPair) GetFlags() ContactPairFlag {
|
||||
return ContactPairFlag(cp.cCp.flags)
|
||||
}
|
||||
|
||||
func (cp *ContactPair) GetEvents() PairFlags {
|
||||
return PairFlags(cp.cCp.events)
|
||||
}
|
||||
|
||||
func (cp *ContactPair) GetPatchCount() int {
|
||||
return int(cp.cCp.patchCount)
|
||||
}
|
||||
|
||||
func (cp *ContactPair) GetContactPointCount() int {
|
||||
return int(cp.cCp.contactCount)
|
||||
}
|
||||
|
||||
func (cp *ContactPair) GetContactPoints() []ContactPairPoint {
|
||||
|
||||
ccps := make([]ContactPairPoint, cp.cCp.contactCount)
|
||||
extractedPoints := unsafe.Slice(cp.cCp.extractedContactPoints, cp.cCp.contactCount)
|
||||
for i := 0; i < len(extractedPoints); i++ {
|
||||
ccps[i].cCpp = &extractedPoints[i]
|
||||
}
|
||||
|
||||
return ccps
|
||||
}
|
||||
|
||||
type ContactPairPoint struct {
|
||||
cCpp *C.struct_CPxContactPairPoint
|
||||
}
|
||||
|
||||
func (cpp *ContactPairPoint) GetPos() gglm.Vec3 {
|
||||
return gglm.Vec3{Data: [3]float32{
|
||||
float32(cpp.cCpp.position.x),
|
||||
float32(cpp.cCpp.position.y),
|
||||
float32(cpp.cCpp.position.z),
|
||||
}}
|
||||
}
|
||||
|
||||
func (cpp *ContactPairPoint) GetImpulse() gglm.Vec3 {
|
||||
return gglm.Vec3{Data: [3]float32{
|
||||
float32(cpp.cCpp.impulse.x),
|
||||
float32(cpp.cCpp.impulse.y),
|
||||
float32(cpp.cCpp.impulse.z),
|
||||
}}
|
||||
}
|
||||
|
||||
func (cpp *ContactPairPoint) GetNormal() gglm.Vec3 {
|
||||
return gglm.Vec3{Data: [3]float32{
|
||||
float32(cpp.cCpp.normal.x),
|
||||
float32(cpp.cCpp.normal.y),
|
||||
float32(cpp.cCpp.normal.z),
|
||||
}}
|
||||
}
|
||||
|
||||
func (cpp *ContactPairPoint) GetSeparation() float32 {
|
||||
return float32(cpp.cCpp.separation)
|
||||
}
|
||||
|
||||
func (cpp *ContactPairPoint) GetInternalFaceIndices() (float32, float32) {
|
||||
return float32(cpp.cCpp.internalFaceIndex0), float32(cpp.cCpp.internalFaceIndex1)
|
||||
}
|
||||
|
||||
type PvdSceneFlag uint32
|
||||
|
||||
const (
|
||||
@ -383,7 +478,9 @@ func (sg *SphereGeometry) ToGeometry() *Geometry {
|
||||
// struct CPxSphereGeometry NewCPxSphereGeometry(CPxReal radius);
|
||||
func NewSphereGeometry(radius float32) *SphereGeometry {
|
||||
return &SphereGeometry{
|
||||
cSg: C.NewCPxSphereGeometry(C.float(radius)),
|
||||
cSg: C.struct_CPxSphereGeometry{
|
||||
radius: C.float(radius),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,7 +496,11 @@ func (bg *BoxGeometry) ToGeometry() *Geometry {
|
||||
|
||||
func NewBoxGeometry(hx, hy, hz float32) *BoxGeometry {
|
||||
return &BoxGeometry{
|
||||
cBg: C.NewCPxBoxGeometry(C.float(hx), C.float(hy), C.float(hz)),
|
||||
cBg: C.struct_CPxBoxGeometry{
|
||||
hx: C.float(hx),
|
||||
hy: C.float(hy),
|
||||
hz: C.float(hz),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,7 +516,10 @@ func (bg *CapsuleGeometry) ToGeometry() *Geometry {
|
||||
|
||||
func NewCapsuleGeometry(radius, halfHeight float32) *CapsuleGeometry {
|
||||
return &CapsuleGeometry{
|
||||
cCg: C.NewCPxCapsuleGeometry(C.float(radius), C.float(halfHeight)),
|
||||
cCg: C.struct_CPxCapsuleGeometry{
|
||||
radius: C.float(radius),
|
||||
halfHeight: C.float(halfHeight),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,15 @@ extern "C" {
|
||||
float hx, hy, hz;
|
||||
};
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxBoxGeometry NewCPxBoxGeometry(float hx, float hy, float hz);
|
||||
CPxAPI CPxInline CSTRUCT CPxBoxGeometry NewCPxBoxGeometry(float hx, float hy, float hz)
|
||||
{
|
||||
CSTRUCT CPxBoxGeometry cbg;
|
||||
cbg.hx = hx;
|
||||
cbg.hy = hy;
|
||||
cbg.hz = hz;
|
||||
|
||||
return cbg;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -10,7 +10,13 @@ extern "C" {
|
||||
CPxReal radius, halfHeight;
|
||||
};
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxCapsuleGeometry NewCPxCapsuleGeometry(CPxReal radius, CPxReal halfHeight);
|
||||
CPxAPI CPxInline CSTRUCT CPxCapsuleGeometry NewCPxCapsuleGeometry(CPxReal radius, CPxReal halfHeight)
|
||||
{
|
||||
CSTRUCT CPxCapsuleGeometry c;
|
||||
c.radius = radius;
|
||||
c.halfHeight = halfHeight;
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -269,34 +269,55 @@ extern "C" {
|
||||
CPxPairFlags_eTRIGGER_DEFAULT = CPxPairFlags_eNOTIFY_TOUCH_FOUND | CPxPairFlags_eNOTIFY_TOUCH_LOST | CPxPairFlags_eDETECT_DISCRETE_CONTACT
|
||||
};
|
||||
|
||||
//TODO: uintxx_t not available again
|
||||
struct CPxContactPairPoint
|
||||
{
|
||||
/**
|
||||
\brief The position of the contact point between the shapes, in world space.
|
||||
*/
|
||||
CSTRUCT CPxVec3 position;
|
||||
|
||||
/**
|
||||
\brief The separation of the shapes at the contact point. A negative separation denotes a penetration.
|
||||
*/
|
||||
CPxReal separation;
|
||||
|
||||
/**
|
||||
\brief The normal of the contacting surfaces at the contact point. The normal direction points from the second shape to the first shape.
|
||||
*/
|
||||
CSTRUCT CPxVec3 normal;
|
||||
|
||||
/**
|
||||
\brief The surface index of shape 0 at the contact point. This is used to identify the surface material.
|
||||
*/
|
||||
CPxU32 internalFaceIndex0;
|
||||
|
||||
/**
|
||||
\brief The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value.
|
||||
*/
|
||||
CSTRUCT CPxVec3 impulse;
|
||||
|
||||
/**
|
||||
\brief The surface index of shape 1 at the contact point. This is used to identify the surface material.
|
||||
*/
|
||||
CPxU32 internalFaceIndex1;
|
||||
};
|
||||
|
||||
struct CPxContactPair
|
||||
{
|
||||
CSTRUCT CPxShape shapes[2];
|
||||
|
||||
char* contactPatches;
|
||||
//const PxU8* contactPatches;
|
||||
|
||||
char* contactPoints;
|
||||
//const PxU8* contactPoints;
|
||||
|
||||
CPxU8* contactPatches;
|
||||
CPxU8* contactPoints;
|
||||
CPxReal* contactImpulses;
|
||||
CPxU32 requiredBufferSize;
|
||||
CPxU8 contactCount;
|
||||
CPxU8 patchCount;
|
||||
CPxU16 contactStreamSize;
|
||||
|
||||
unsigned int requiredBufferSize;
|
||||
//CPxU32 requiredBufferSize;
|
||||
|
||||
char contactCount;
|
||||
//PxU8 contactCount;
|
||||
|
||||
char patchCount;
|
||||
//PxU8 patchCount;
|
||||
|
||||
short contactStreamSize;
|
||||
//PxU16 contactStreamSize;
|
||||
|
||||
CENUM CPxContactPairFlag flags;
|
||||
CENUM CPxPairFlags events;
|
||||
CENUM CPxContactPairFlag flags;
|
||||
|
||||
CSTRUCT CPxContactPairPoint* extractedContactPoints;
|
||||
};
|
||||
|
||||
enum CPxContactPairHeaderFlag
|
||||
@ -309,17 +330,13 @@ extern "C" {
|
||||
{
|
||||
CSTRUCT CPxRigidActor actors[2];
|
||||
|
||||
char* extraDataStream;
|
||||
short extraDataStreamSize;
|
||||
/*CPxU8* extraDataStream;
|
||||
CPxU16 extraDataStreamSize;*/
|
||||
CPxU8* extraDataStream;
|
||||
CPxU16 extraDataStreamSize;
|
||||
|
||||
CENUM CPxContactPairHeaderFlag flags;
|
||||
|
||||
CSTRUCT CPxContactPair* pairs;
|
||||
|
||||
unsigned int nbPairs;
|
||||
//CPxU32 nbPairs;
|
||||
CPxU32 nbPairs;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
#ifndef CPxDefaultSimulationFilterShader_H
|
||||
#define CPxDefaultSimulationFilterShader_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct CPxDefaultSimulationFilterShader
|
||||
{
|
||||
void* obj;
|
||||
};
|
||||
|
||||
//CPxAPI CSTRUCT CPxDefaultSimulationFilterShader* NewCPxDefaultSimulationFilterShader();
|
||||
//CPxAPI void FreeCPxDefaultSimulationFilterShader(CSTRUCT CPxDefaultSimulationFilterShader*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // !CPxDefaultSimulationFilterShader_H
|
||||
@ -1,22 +1,18 @@
|
||||
#ifndef CPxFilterData_H
|
||||
#define CPxFilterData_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct CPxFilterData
|
||||
{
|
||||
unsigned int word0;
|
||||
unsigned int word1;
|
||||
unsigned int word2;
|
||||
unsigned int word3;
|
||||
|
||||
//TODO: For some reason only this file breaks with CPxU32 (uint32_t). Why?
|
||||
/*CPxU32 word0;
|
||||
CPxU32 word0;
|
||||
CPxU32 word1;
|
||||
CPxU32 word2;
|
||||
CPxU32 word3;*/
|
||||
CPxU32 word3;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -28,14 +28,55 @@ extern "C" {
|
||||
CENUM CPxGeometryType type;
|
||||
};
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxSphereGeometry CPxGeometry_toCPxSphereGeometry(CSTRUCT CPxGeometry);
|
||||
CPxAPI CPxInline CSTRUCT CPxGeometry CPxSphereGeometry_toCPxGeometry(CSTRUCT CPxSphereGeometry*);
|
||||
//
|
||||
// CPxSphereGeometry
|
||||
//
|
||||
CPxAPI CPxInline CSTRUCT CPxSphereGeometry CPxGeometry_toCPxSphereGeometry(CSTRUCT CPxGeometry cg)
|
||||
{
|
||||
return *(CSTRUCT CPxSphereGeometry*)(cg.obj);
|
||||
//return *static_cast<CSTRUCT CPxSphereGeometry*>(cg.obj);
|
||||
}
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxBoxGeometry CPxGeometry_toCPxBoxGeometry(CSTRUCT CPxGeometry);
|
||||
CPxAPI CPxInline CSTRUCT CPxGeometry CPxBoxGeometry_toCPxGeometry(CSTRUCT CPxBoxGeometry*);
|
||||
CPxAPI CPxInline CSTRUCT CPxGeometry CPxSphereGeometry_toCPxGeometry(CSTRUCT CPxSphereGeometry* csg)
|
||||
{
|
||||
CSTRUCT CPxGeometry g;
|
||||
g.obj = csg;
|
||||
g.type = CPxGeometryType_eSPHERE;
|
||||
return g;
|
||||
}
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxCapsuleGeometry CPxGeometry_toCPxCapsuleGeometry(CSTRUCT CPxGeometry);
|
||||
CPxAPI CPxInline CSTRUCT CPxGeometry CPxCapsuleGeometry_toCPxGeometry(CSTRUCT CPxCapsuleGeometry*);
|
||||
//
|
||||
// CPxBoxGeometry
|
||||
//
|
||||
CPxAPI CPxInline CSTRUCT CPxBoxGeometry CPxGeometry_toCPxBoxGeometry(CSTRUCT CPxGeometry cg)
|
||||
{
|
||||
return *(CSTRUCT CPxBoxGeometry*)(cg.obj);
|
||||
//return *static_cast<CSTRUCT CPxBoxGeometry*>(cg.obj);
|
||||
}
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxGeometry CPxBoxGeometry_toCPxGeometry(CSTRUCT CPxBoxGeometry* cbg)
|
||||
{
|
||||
CSTRUCT CPxGeometry g;
|
||||
g.obj = cbg;
|
||||
g.type = CPxGeometryType_eBOX;
|
||||
return g;
|
||||
}
|
||||
|
||||
//
|
||||
// CPxCapsuleGeometry
|
||||
//
|
||||
CPxAPI CPxInline CSTRUCT CPxCapsuleGeometry CPxGeometry_toCPxCapsuleGeometry(CSTRUCT CPxGeometry cg)
|
||||
{
|
||||
return *(CSTRUCT CPxCapsuleGeometry*)(cg.obj);
|
||||
}
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxGeometry CPxCapsuleGeometry_toCPxGeometry(CSTRUCT CPxCapsuleGeometry* ccg)
|
||||
{
|
||||
CSTRUCT CPxGeometry g;
|
||||
g.obj = ccg;
|
||||
g.type = CPxGeometryType_eCAPSULE;
|
||||
return g;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//TODO: Maybe convert this into a value type like CPxSphereGeometry?
|
||||
//NOTE: Maybe convert this into a value type like CPxSphereGeometry?
|
||||
struct CPxPlane
|
||||
{
|
||||
void* obj;
|
||||
|
||||
@ -10,8 +10,17 @@ extern "C" {
|
||||
float x, y, z, w;
|
||||
};
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxQuat NewCPxQuat(float angleRads, float x, float y, float z);
|
||||
CPxAPI CPxInline CSTRUCT CPxQuat NewCPxQuatXYZW(float x, float y, float z, float w);
|
||||
CPxAPI CSTRUCT CPxQuat NewCPxQuat(float angleRads, float x, float y, float z);
|
||||
CPxAPI CPxInline CSTRUCT CPxQuat NewCPxQuatXYZW(float x, float y, float z, float w)
|
||||
{
|
||||
CSTRUCT CPxQuat q;
|
||||
q.x = x;
|
||||
q.y = y;
|
||||
q.z = z;
|
||||
q.w = w;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -11,11 +11,33 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum CPxHitFlag
|
||||
{
|
||||
CPxHitFlag_ePOSITION = (1 << 0), //!< "position" member of #PxQueryHit is valid
|
||||
CPxHitFlag_eNORMAL = (1 << 1), //!< "normal" member of #PxQueryHit is valid
|
||||
CPxHitFlag_eUV = (1 << 3), //!< "u" and "v" barycentric coordinates of #PxQueryHit are valid. Not applicable to sweep queries.
|
||||
CPxHitFlag_eASSUME_NO_INITIAL_OVERLAP = (1 << 4), //!< Performance hint flag for sweeps when it is known upfront there's no initial overlap.
|
||||
//!< NOTE: using this flag may cause undefined results if shapes are initially overlapping.
|
||||
CPxHitFlag_eMESH_MULTIPLE = (1 << 5), //!< Report all hits for meshes rather than just the first. Not applicable to sweep queries.
|
||||
CPxHitFlag_eMESH_ANY = (1 << 6), //!< Report any first hit for meshes. If neither eMESH_MULTIPLE nor eMESH_ANY is specified,
|
||||
//!< a single closest hit will be reported for meshes.
|
||||
CPxHitFlag_eMESH_BOTH_SIDES = (1 << 7), //!< Report hits with back faces of mesh triangles. Also report hits for raycast
|
||||
//!< originating on mesh surface and facing away from the surface normal. Not applicable to sweep queries.
|
||||
//!< Please refer to the user guide for heightfield-specific differences.
|
||||
CPxHitFlag_ePRECISE_SWEEP = (1 << 8), //!< Use more accurate but slower narrow phase sweep tests.
|
||||
//!< May provide better compatibility with PhysX 3.2 sweep behavior.
|
||||
CPxHitFlag_eMTD = (1 << 9), //!< Report the minimum translation depth, normal and contact point.
|
||||
CPxHitFlag_eFACE_INDEX = (1 << 10), //!< "face index" member of #PxQueryHit is valid
|
||||
CPxHitFlag_eDEFAULT = CPxHitFlag_ePOSITION | CPxHitFlag_eNORMAL | CPxHitFlag_eFACE_INDEX,
|
||||
/** \brief Only this subset of flags can be modified by pre-filter. Other modifications will be discarded. */
|
||||
CPxHitFlag_eMODIFIABLE_FLAGS = CPxHitFlag_eMESH_MULTIPLE | CPxHitFlag_eMESH_BOTH_SIDES | CPxHitFlag_eASSUME_NO_INITIAL_OVERLAP | CPxHitFlag_ePRECISE_SWEEP
|
||||
};
|
||||
|
||||
struct CPxRaycastHit
|
||||
{
|
||||
//CPxHitFlags flags; //!< Hit flags specifying which members contain valid values.
|
||||
struct CPxVec3 position; //!< World-space hit position (flag: #PxHitFlag::ePOSITION)
|
||||
struct CPxVec3 normal; //!< World-space hit normal (flag: #PxHitFlag::eNORMAL)
|
||||
CENUM CPxHitFlag flags; //!< Hit flags specifying which members contain valid values.
|
||||
CSTRUCT CPxVec3 position; //!< World-space hit position (flag: #PxHitFlag::ePOSITION)
|
||||
CSTRUCT CPxVec3 normal; //!< World-space hit normal (flag: #PxHitFlag::eNORMAL)
|
||||
|
||||
/**
|
||||
\brief Distance to hit.
|
||||
@ -24,14 +46,14 @@ extern "C" {
|
||||
CPxF32 distance;
|
||||
CPxReal u, v;
|
||||
CPxU32 faceIndex;
|
||||
struct CPxShape shape;
|
||||
struct CPxRigidActor actor;
|
||||
CSTRUCT CPxShape shape;
|
||||
CSTRUCT CPxRigidActor actor;
|
||||
};
|
||||
|
||||
struct CPxRaycastBuffer
|
||||
{
|
||||
struct CPxRaycastHit block;
|
||||
struct CPxRaycastHit* touches;
|
||||
CSTRUCT CPxRaycastHit block;
|
||||
CSTRUCT CPxRaycastHit* touches;
|
||||
CPxU32 nbTouches;
|
||||
bool hasBlock;
|
||||
};
|
||||
@ -58,7 +80,7 @@ extern "C" {
|
||||
/// If multiples passed are zero then any existing buffers are cleared
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
CPxAPI void CPxScene_setScratchBuffer(CSTRUCT CPxScene*, uint32_t multiplesOf16k);
|
||||
CPxAPI void CPxScene_setScratchBuffer(CSTRUCT CPxScene*, CPxU32 multiplesOf16k);
|
||||
|
||||
CPxAPI void CPxScene_release(CSTRUCT CPxScene*);
|
||||
|
||||
|
||||
@ -10,7 +10,12 @@ extern "C" {
|
||||
CPxReal radius;
|
||||
};
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxSphereGeometry NewCPxSphereGeometry(CPxReal radius);
|
||||
CPxAPI CPxInline CSTRUCT CPxSphereGeometry NewCPxSphereGeometry(CPxReal radius)
|
||||
{
|
||||
CSTRUCT CPxSphereGeometry c;
|
||||
c.radius = radius;
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -14,7 +14,14 @@ extern "C" {
|
||||
CSTRUCT CPxQuat q;
|
||||
};
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxTransform NewCPxTransform(CSTRUCT CPxVec3*, CSTRUCT CPxQuat*);
|
||||
CPxAPI CPxInline CSTRUCT CPxTransform NewCPxTransform(CSTRUCT CPxVec3* v, CSTRUCT CPxQuat* q)
|
||||
{
|
||||
CSTRUCT CPxTransform t;
|
||||
t.p = *v;
|
||||
t.q = *q;
|
||||
|
||||
return t;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -9,7 +9,15 @@ extern "C" {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
CPxAPI CPxInline CSTRUCT CPxVec3 NewCPxVec3(float x, float y, float z);
|
||||
CPxAPI CPxInline CSTRUCT CPxVec3 NewCPxVec3(float x, float y, float z)
|
||||
{
|
||||
CSTRUCT CPxVec3 v;
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
v.z = z;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
10
pgo/pvdInstrumentationFlag.go
Executable file
10
pgo/pvdInstrumentationFlag.go
Executable file
@ -0,0 +1,10 @@
|
||||
package pgo
|
||||
|
||||
type PvdInstrumentationFlag uint32
|
||||
|
||||
const (
|
||||
PvdInstrumentationFlag_eDEBUG PvdInstrumentationFlag = 1 << 0
|
||||
PvdInstrumentationFlag_ePROFILE PvdInstrumentationFlag = 1 << 1
|
||||
PvdInstrumentationFlag_eMEMORY PvdInstrumentationFlag = 1 << 2
|
||||
PvdInstrumentationFlag_eALL PvdInstrumentationFlag = (PvdInstrumentationFlag_eDEBUG | PvdInstrumentationFlag_ePROFILE | PvdInstrumentationFlag_eMEMORY)
|
||||
)
|
||||
@ -2,12 +2,14 @@
|
||||
#include <stdbool.h>
|
||||
#define CPxAPI
|
||||
#define CPxInternalAPI
|
||||
#define CPxInline
|
||||
#define CPxInline inline
|
||||
#define CSTRUCT struct
|
||||
#define CENUM enum
|
||||
#define CPxU32 uint32_t
|
||||
#define CPxReal float
|
||||
#define CPxF32 float
|
||||
#define CPxU8 uint8_t
|
||||
#define CPxU16 uint16_t
|
||||
|
||||
#include <CPxFoundation.h>
|
||||
#include <CPxPvd.h>
|
||||
|
||||
Reference in New Issue
Block a user