11/*
2- Copyright (c) 2024 Stephen Gold
2+ Copyright (c) 2024-2025 Stephen Gold
33
44Permission is hereby granted, free of charge, to any person obtaining a copy
55of this software and associated documentation files (the "Software"), to deal
@@ -85,7 +85,7 @@ class CustomCharacterContactListener : CharacterContactListener {
8585 const Body &inBody2, Vec3 &ioLinearVelocity,
8686 Vec3 &ioAngularVelocity) {
8787 JNIEnv *pAttachEnv;
88- jint retCode = mpVM-> AttachCurrentThread (( void **) &pAttachEnv, NULL );
88+ jint retCode = ATTACH_CURRENT_THREAD (mpVM, &pAttachEnv);
8989 JPH_ASSERT (retCode == JNI_OK);
9090
9191 const jlong characterVa = reinterpret_cast <jlong> (inCharacter);
@@ -121,7 +121,7 @@ class CustomCharacterContactListener : CharacterContactListener {
121121 const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition,
122122 Vec3Arg inContactNormal, CharacterContactSettings &ioSettings) {
123123 JNIEnv *pAttachEnv;
124- jint retCode = mpVM-> AttachCurrentThread (( void **) &pAttachEnv, NULL );
124+ jint retCode = ATTACH_CURRENT_THREAD (mpVM, &pAttachEnv);
125125 JPH_ASSERT (retCode == JNI_OK);
126126
127127 const jlong characterVa = reinterpret_cast <jlong> (inCharacter);
@@ -152,7 +152,7 @@ class CustomCharacterContactListener : CharacterContactListener {
152152 const PhysicsMaterial *inContactMaterial,
153153 Vec3Arg inCharacterVelocity, Vec3 &ioNewCharacterVelocity) {
154154 JNIEnv *pAttachEnv;
155- jint retCode = mpVM-> AttachCurrentThread (( void **) &pAttachEnv, NULL );
155+ jint retCode = ATTACH_CURRENT_THREAD (mpVM, &pAttachEnv);
156156 JPH_ASSERT (retCode == JNI_OK);
157157
158158 const jlong characterVa = reinterpret_cast <jlong> (inCharacter);
@@ -205,7 +205,7 @@ class CustomCharacterContactListener : CharacterContactListener {
205205 const CharacterVirtual *inOtherCharacter,
206206 const SubShapeID &inSubShapeID2) {
207207 JNIEnv *pAttachEnv;
208- jint retCode = mpVM-> AttachCurrentThread (( void **) &pAttachEnv, NULL );
208+ jint retCode = ATTACH_CURRENT_THREAD (mpVM, &pAttachEnv);
209209 JPH_ASSERT (retCode == JNI_OK);
210210
211211 const jlong characterVa = reinterpret_cast <jlong> (inCharacter);
@@ -225,7 +225,7 @@ class CustomCharacterContactListener : CharacterContactListener {
225225 RVec3Arg inContactPosition, Vec3Arg inContactNormal,
226226 CharacterContactSettings &ioSettings) {
227227 JNIEnv *pAttachEnv;
228- jint retCode = mpVM-> AttachCurrentThread (( void **) &pAttachEnv, NULL );
228+ jint retCode = ATTACH_CURRENT_THREAD (mpVM, &pAttachEnv);
229229 JPH_ASSERT (retCode == JNI_OK);
230230
231231 const jlong characterVa = reinterpret_cast <jlong> (inCharacter);
@@ -254,7 +254,7 @@ class CustomCharacterContactListener : CharacterContactListener {
254254 Vec3Arg inContactVelocity, const PhysicsMaterial *inContactMaterial,
255255 Vec3Arg inCharacterVelocity, Vec3 &ioNewCharacterVelocity) {
256256 JNIEnv *pAttachEnv;
257- jint retCode = mpVM-> AttachCurrentThread (( void **) &pAttachEnv, NULL );
257+ jint retCode = ATTACH_CURRENT_THREAD (mpVM, &pAttachEnv);
258258 JPH_ASSERT (retCode == JNI_OK);
259259
260260 const jlong characterVa = reinterpret_cast <jlong> (inCharacter);
@@ -304,7 +304,7 @@ class CustomCharacterContactListener : CharacterContactListener {
304304 bool OnContactValidate (const CharacterVirtual *inCharacter,
305305 const BodyID &inBodyID2, const SubShapeID &inSubShapeID2) {
306306 JNIEnv *pAttachEnv;
307- jint retCode = mpVM-> AttachCurrentThread (( void **) &pAttachEnv, NULL );
307+ jint retCode = ATTACH_CURRENT_THREAD (mpVM, &pAttachEnv);
308308 JPH_ASSERT (retCode == JNI_OK);
309309
310310 const jlong characterVa = reinterpret_cast <jlong> (inCharacter);
@@ -319,7 +319,7 @@ class CustomCharacterContactListener : CharacterContactListener {
319319
320320 ~CustomCharacterContactListener () {
321321 JNIEnv *pAttachEnv;
322- jint retCode = mpVM-> AttachCurrentThread (( void **) &pAttachEnv, NULL );
322+ jint retCode = ATTACH_CURRENT_THREAD (mpVM, &pAttachEnv);
323323 JPH_ASSERT (retCode == JNI_OK);
324324
325325 pAttachEnv->DeleteGlobalRef (mJavaObject );
0 commit comments