Skip to content

Commit 125a50c

Browse files
committed
ConstCharacterBase: add another getShape() signature
1 parent b262499 commit 125a50c

File tree

7 files changed

+89
-0
lines changed

7 files changed

+89
-0
lines changed

src/main/java/com/github/stephengold/joltjni/CharacterBase.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,19 @@ public ConstShape getShape() {
241241
return result;
242242
}
243243

244+
/**
245+
* Update the specified counted reference to refer to the character's shape.
246+
* The character is unaffected.
247+
*
248+
* @param storeRef storage for the reference (not {@code null}, modified)
249+
*/
250+
@Override
251+
public void getShape(ShapeRefC storeRef) {
252+
long characterVa = va();
253+
long refVa = storeRef.va();
254+
getShapeUpdate(characterVa, refVa);
255+
}
256+
244257
/**
245258
* Copy the character's "up" direction. The character is unaffected.
246259
*
@@ -352,6 +365,8 @@ native static void getGroundVelocity(
352365

353366
native static long getShape(long characterVa);
354367

368+
native static void getShapeUpdate(long characterVa, long refVa);
369+
355370
native static void getUp(long characterVa, FloatBuffer storeFloats);
356371

357372
native static boolean isSlopeTooSteep(

src/main/java/com/github/stephengold/joltjni/CharacterRef.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,19 @@ public ConstShape getShape() {
660660
return result;
661661
}
662662

663+
/**
664+
* Update the specified counted reference to refer to the character's shape.
665+
* The character is unaffected.
666+
*
667+
* @param storeRef storage for the reference (not {@code null}, modified)
668+
*/
669+
@Override
670+
public void getShape(ShapeRefC storeRef) {
671+
long characterVa = targetVa();
672+
long refVa = storeRef.va();
673+
CharacterBase.getShapeUpdate(characterVa, refVa);
674+
}
675+
663676
/**
664677
* Generate a TransformedShape that represents the volume occupied by the
665678
* character, using the locking body interface. The character is unaffected.

src/main/java/com/github/stephengold/joltjni/CharacterRefC.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,19 @@ public ConstShape getShape() {
482482
return result;
483483
}
484484

485+
/**
486+
* Update the specified counted reference to refer to the character's shape.
487+
* The character is unaffected.
488+
*
489+
* @param storeRef storage for the reference (not {@code null}, modified)
490+
*/
491+
@Override
492+
public void getShape(ShapeRefC storeRef) {
493+
long characterVa = targetVa();
494+
long refVa = storeRef.va();
495+
CharacterBase.getShapeUpdate(characterVa, refVa);
496+
}
497+
485498
/**
486499
* Generate a TransformedShape that represents the volume occupied by the
487500
* character, using the locking body interface. The character is unaffected.

src/main/java/com/github/stephengold/joltjni/CharacterVirtualRef.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,19 @@ public ConstShape getShape() {
741741
return result;
742742
}
743743

744+
/**
745+
* Update the specified counted reference to refer to the character's shape.
746+
* The character is unaffected.
747+
*
748+
* @param storeRef storage for the reference (not {@code null}, modified)
749+
*/
750+
@Override
751+
public void getShape(ShapeRefC storeRef) {
752+
long characterVa = targetVa();
753+
long refVa = storeRef.va();
754+
CharacterBase.getShapeUpdate(characterVa, refVa);
755+
}
756+
744757
/**
745758
* Copy the local offset applied to the shape. The character is unaffected.
746759
*

src/main/java/com/github/stephengold/joltjni/CharacterVirtualRefC.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,19 @@ public ConstShape getShape() {
569569
return result;
570570
}
571571

572+
/**
573+
* Update the specified counted reference to refer to the character's shape.
574+
* The character is unaffected.
575+
*
576+
* @param storeRef storage for the reference (not {@code null}, modified)
577+
*/
578+
@Override
579+
public void getShape(ShapeRefC storeRef) {
580+
long characterVa = targetVa();
581+
long refVa = storeRef.va();
582+
CharacterBase.getShapeUpdate(characterVa, refVa);
583+
}
584+
572585
/**
573586
* Copy the local offset applied to the shape. The character is unaffected.
574587
*

src/main/java/com/github/stephengold/joltjni/readonly/ConstCharacterBase.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ of this software and associated documentation files (the "Software"), to deal
2222
package com.github.stephengold.joltjni.readonly;
2323

2424
import com.github.stephengold.joltjni.RVec3;
25+
import com.github.stephengold.joltjni.ShapeRefC;
2526
import com.github.stephengold.joltjni.StateRecorder;
2627
import com.github.stephengold.joltjni.Vec3;
2728
import com.github.stephengold.joltjni.enumerate.EGroundState;
@@ -122,6 +123,14 @@ public interface ConstCharacterBase extends ConstJoltPhysicsObject {
122123
*/
123124
ConstShape getShape();
124125

126+
/**
127+
* Update the specified counted reference to refer to the character's shape.
128+
* The character is unaffected.
129+
*
130+
* @param storeRef storage for the reference (not {@code null}, modified)
131+
*/
132+
void getShape(ShapeRefC storeRef);
133+
125134
/**
126135
* Copy the character's "up" direction. The character is unaffected.
127136
*

src/main/native/glue/ch/CharacterBase.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ JNIEXPORT jlong JNICALL Java_com_github_stephengold_joltjni_CharacterBase_getSha
185185
return reinterpret_cast<jlong> (pResult);
186186
}
187187

188+
/*
189+
* Class: com_github_stephengold_joltjni_CharacterBase
190+
* Method: getShapeUpdate
191+
* Signature: (JJ)V
192+
*/
193+
JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_CharacterBase_getShapeUpdate
194+
(JNIEnv *, jclass, jlong characterVa, jlong refVa) {
195+
const CharacterBase * const pCharacter
196+
= reinterpret_cast<CharacterBase *> (characterVa);
197+
RefConst<Shape> * const pRef = reinterpret_cast<RefConst<Shape> *> (refVa);
198+
(*pRef) = pCharacter->GetShape();
199+
}
200+
188201
/*
189202
* Class: com_github_stephengold_joltjni_CharacterBase
190203
* Method: getUp

0 commit comments

Comments
 (0)