pvd debug and PxHeightField
hello, I have two question about physx-jni. The one is I want use pvd debug, but compare to office example, i can't create PvdDefaultSocketTransport object. so how to solve the problem. if can use pvd debug , i can create object in code and see the change in pvd debug. Other is how to create PxHeightField. I'm not found create code.
PVD is not supported out-of-the-box yet. However, you should be able to use it by sub-classing JSPvdTransport and implementing the connect() and send() methods.
For and PxHeightField example you can take a look at my kool implementation, although that is written in kotlin.
Essentialy, you need to create a Vector_PxHeightFieldSample and fill that with your height samples. Then, create a PxHeightFieldDesc and set it up according to your height field size (lines 47 to 52 in the code linked above). Finally, use PxCooking to create the PxHeightField and wrap that into a PxHeightFieldGeoemtry to use it.
About PVD, I code a java class who inherits JSPvdTransport, but I don't know how to implementing send method. How to gain the byte array data in NativeObject.
Yes getting the native data is a bit problematic. Unfortunately there is no easy to use convenience function, which provides a byte array or something like that.
Your best option is probably to use Unsafe.getUnsafe().getByte() or Unsafe.getUnsafe().copyMemory() (assuming you are on java 11+, otherwise it's a bit more difficult to get an Unsafe instance, Google will help)
Edit: A simpler way might be to wrap the inBytes object into a PxU8ConstPtr and use TypeHelpers to read the bytes:
@Override
public void send(NativeObject inBytes, int inLength) {
PxU8ConstPtr ptr = PxU8ConstPtr.wrapPointer(inBytes.getAddress());
byte[] data = new byte[inLength];
for (int i = 0; i < inLength; i++) {
data[i] = TypeHelpers.getU8At(ptr, i);
}
// send data...
}
I use the function what you provide, but its happends an error. I used java8.
The following are console printing errors.
A fatal error has been detected by the Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffe79134916, pid=16984, tid=0x0000000000002318
JRE version: Java(TM) SE Runtime Environment (8.0_211-b12) (build 1.8.0_211-b12) Java VM: Java HotSpot(TM) 64-Bit Server VM (25.211-b12 mixed mode windows-amd64 compressed oops) Problematic frame: C [PhysXJniBindings_64.dll+0x14916]
Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
An error report file with more information is saved as: E:\code\server\scenegs\hs_err_pid16984.log If you would like to submit a bug report, please visit: http://bugreport.java.com/bugreport/crash.jsp The crash happened outside the Java Virtual Machine in native code. See problematic frame for where to report the bug.