mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 07:58:20 +00:00
Implement SetScratchBuffer
This commit is contained in:
3
main.go
3
main.go
@ -73,6 +73,9 @@ func main() {
|
|||||||
println("Box 2 mass:", dynBox2.GetMass())
|
println("Box 2 mass:", dynBox2.GetMass())
|
||||||
println("Sphere mass:", dynSphere.GetMass())
|
println("Sphere mass:", dynSphere.GetMass())
|
||||||
println("Capsule mass:", dynCapsule.GetMass())
|
println("Capsule mass:", dynCapsule.GetMass())
|
||||||
|
|
||||||
|
s.SetScratchBuffer(4)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
s.Simulate(1 / 60.0)
|
s.Simulate(1 / 60.0)
|
||||||
s.FetchResults(true)
|
s.FetchResults(true)
|
||||||
|
|||||||
Binary file not shown.
@ -95,12 +95,10 @@ func (s *Scene) AddActor(a *Actor) {
|
|||||||
C.CPxScene_addActor(s.cS, a.cA)
|
C.CPxScene_addActor(s.cS, a.cA)
|
||||||
}
|
}
|
||||||
|
|
||||||
// void CPxScene_simulate(CSTRUCT CPxScene*, CPxReal elapsedTime);
|
|
||||||
func (s *Scene) Simulate(elapsedTime float32) {
|
func (s *Scene) Simulate(elapsedTime float32) {
|
||||||
C.CPxScene_simulate(s.cS, C.float(elapsedTime))
|
C.CPxScene_simulate(s.cS, C.float(elapsedTime))
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool CPxScene_fetchResults(struct CPxScene*, bool block, CPxU32* errorState);
|
|
||||||
func (s *Scene) FetchResults(block bool) (bool, uint32) {
|
func (s *Scene) FetchResults(block bool) (bool, uint32) {
|
||||||
|
|
||||||
var errState uint32
|
var errState uint32
|
||||||
@ -108,6 +106,10 @@ func (s *Scene) FetchResults(block bool) (bool, uint32) {
|
|||||||
return bool(b), errState
|
return bool(b), errState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Scene) SetScratchBuffer(multiplesOf16k uint32) {
|
||||||
|
C.CPxScene_setScratchBuffer(s.cS, C.uint(multiplesOf16k))
|
||||||
|
}
|
||||||
|
|
||||||
type Physics struct {
|
type Physics struct {
|
||||||
cPhysics *C.struct_CPxPhysics
|
cPhysics *C.struct_CPxPhysics
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,8 @@ extern "C" {
|
|||||||
struct CPxScene
|
struct CPxScene
|
||||||
{
|
{
|
||||||
void* obj;
|
void* obj;
|
||||||
|
void* scratchBuffer;
|
||||||
|
CPxU32 scratchBufferSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
CPxAPI CSTRUCT CPxPvdSceneClient* CPxScene_getScenePvdClient(CSTRUCT CPxScene*);
|
CPxAPI CSTRUCT CPxPvdSceneClient* CPxScene_getScenePvdClient(CSTRUCT CPxScene*);
|
||||||
@ -18,6 +20,14 @@ extern "C" {
|
|||||||
CPxAPI void CPxScene_simulate(CSTRUCT CPxScene*, CPxReal elapsedTime);
|
CPxAPI void CPxScene_simulate(CSTRUCT CPxScene*, CPxReal elapsedTime);
|
||||||
CPxAPI bool CPxScene_fetchResults(CSTRUCT CPxScene*, bool block, CPxU32* errorState);
|
CPxAPI bool CPxScene_fetchResults(CSTRUCT CPxScene*, bool block, CPxU32* errorState);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a scratch buffer thats a multiple of 16K to be used by the scene when running CPxScene_simulate.
|
||||||
|
/// The buffer MUST be 16-byte aligned. If a buffer already exists then it is freed and a new one is allocated.
|
||||||
|
/// 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_release(CSTRUCT CPxScene*);
|
CPxAPI void CPxScene_release(CSTRUCT CPxScene*);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user