Skip to content

Commit 33d1d4f

Browse files
committed
MotorCycleControllerSettings: add getters and setters for 6 attributes
1 parent d79a0b0 commit 33d1d4f

2 files changed

Lines changed: 326 additions & 1 deletion

File tree

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

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,86 @@ public MotorcycleControllerSettings(
6666
// *************************************************************************
6767
// new methods exposed
6868

69+
/**
70+
* Return the lean smoothing factor. The settings are unaffected. (native
71+
* attribute: mLeanSmoothingFactor)
72+
*
73+
* @return the factor
74+
*/
75+
public float getLeanSmoothingFactor() {
76+
long settingsVa = va();
77+
float result = getLeanSmoothingFactor(settingsVa);
78+
79+
return result;
80+
}
81+
82+
/**
83+
* Return the spring constant for the lean spring. The settings are
84+
* unaffected. (native attribute: mLeanSpringConstant)
85+
*
86+
* @return the spring constant
87+
*/
88+
public float getLeanSpringConstant() {
89+
long settingsVa = va();
90+
float result = getLeanSpringConstant(settingsVa);
91+
92+
return result;
93+
}
94+
95+
/**
96+
* Return the damping constant for the lean spring. The settings are
97+
* unaffected. (native attribute: mLeanSpringDamping)
98+
*
99+
* @return the damping constant
100+
*/
101+
public float getLeanSpringDamping() {
102+
long settingsVa = va();
103+
float result = getLeanSpringDamping(settingsVa);
104+
105+
return result;
106+
}
107+
108+
/**
109+
* Return the coefficient of additional force to control the lean angle. The
110+
* settings are unaffected. (native attribute:
111+
* mLeanSpringIntegrationCoefficient)
112+
*
113+
* @return the integration coefficient
114+
*/
115+
public float getLeanSpringIntegrationCoefficient() {
116+
long settingsVa = va();
117+
float result = getLeanSpringIntegrationCoefficient(settingsVa);
118+
119+
return result;
120+
}
121+
122+
/**
123+
* Return the rate of decay of the angle integral when the wheels are
124+
* unsupported. The settings are unaffected. (native attribute:
125+
* mLeanSpringIntegrationCoefficientDecay)
126+
*
127+
* @return the rate of decay (per second)
128+
*/
129+
public float getLeanSpringIntegrationCoefficientDecay() {
130+
long settingsVa = va();
131+
float result = getLeanSpringIntegrationCoefficientDecay(settingsVa);
132+
133+
return result;
134+
}
135+
136+
/**
137+
* Return the maximum lean angle (during turns). The settings are
138+
* unaffected. (native attribute: mMaxLeanAngle)
139+
*
140+
* @return the angle (in radians)
141+
*/
142+
public float getMaxLeanAngle() {
143+
long settingsVa = va();
144+
float result = getMaxLeanAngle(settingsVa);
145+
146+
return result;
147+
}
148+
69149
/**
70150
* Copy the argument to the current settings.
71151
*
@@ -76,6 +156,71 @@ public void set(MotorcycleControllerSettings source) {
76156
long sourceVa = source.va();
77157
assign(targetVa, sourceVa);
78158
}
159+
160+
/**
161+
* Alter the lean smoothing factor. (native attribute: mLeanSmoothingFactor)
162+
*
163+
* @param factor the desired factor (default=0.8)
164+
*/
165+
public void setLeanSmoothingFactor(float factor) {
166+
long settingsVa = va();
167+
setLeanSmoothingFactor(settingsVa, factor);
168+
}
169+
170+
/**
171+
* Alter the spring constant for the lean spring. (native attribute:
172+
* mLeanSpringConstant)
173+
*
174+
* @param k the desired spring constant (default=5000)
175+
*/
176+
public void setLeanSpringConstant(float k) {
177+
long settingsVa = va();
178+
setLeanSpringConstant(settingsVa, k);
179+
}
180+
181+
/**
182+
* Alter the damping constant for the lean spring. (native attribute:
183+
* mLeanSpringDamping)
184+
*
185+
* @param damping the desired damping constant (default=1000)
186+
*/
187+
public void setLeanSpringDamping(float damping) {
188+
long settingsVa = va();
189+
setLeanSpringDamping(settingsVa, damping);
190+
}
191+
192+
/**
193+
* Alter the coefficient of additional force to control the lean angle.
194+
* (native attribute: mLeanSpringIntegrationCoefficient)
195+
*
196+
* @param coefficient the desired integration coefficient (default=0)
197+
*/
198+
public void setLeanSpringIntegrationCoefficient(float coefficient) {
199+
long settingsVa = va();
200+
setLeanSpringIntegrationCoefficient(settingsVa, coefficient);
201+
}
202+
203+
/**
204+
* Alter the rate of decay of the angle integral when the wheels are
205+
* unsupported. (native attribute: mLeanSpringIntegrationCoefficientDecay)
206+
*
207+
* @param decay the desired rate of decay (per second, default=4)
208+
*/
209+
public void setLeanSpringIntegrationCoefficientDecay(float decay) {
210+
long settingsVa = va();
211+
setLeanSpringIntegrationCoefficientDecay(settingsVa, decay);
212+
}
213+
214+
/**
215+
* Alter the maximum lean angle (during turns). (native attribute:
216+
* mMaxLeanAngle)
217+
*
218+
* @param angle the desired angle (in radians, default=Pi/4)
219+
*/
220+
public void setMaxLeanAngle(float angle) {
221+
long settingsVa = va();
222+
setMaxLeanAngle(settingsVa, angle);
223+
}
79224
// *************************************************************************
80225
// WheeledVehicleControllerSettings methods
81226

@@ -96,4 +241,34 @@ int controllerTypeOrdinal() {
96241
native private static long createCopy(long originalVa);
97242

98243
native private static long createDefault();
244+
245+
native private static float getLeanSmoothingFactor(long settingsVa);
246+
247+
native private static float getLeanSpringConstant(long settingsVa);
248+
249+
native private static float getLeanSpringDamping(long settingsVa);
250+
251+
native private static float getLeanSpringIntegrationCoefficient(
252+
long settingsVa);
253+
254+
native private static float getLeanSpringIntegrationCoefficientDecay(
255+
long settingsVa);
256+
257+
native private static float getMaxLeanAngle(long settingsVa);
258+
259+
native private static void setLeanSmoothingFactor(
260+
long settingsVa, float factor);
261+
262+
native private static void setLeanSpringConstant(long settingsVa, float k);
263+
264+
native private static void setLeanSpringDamping(
265+
long settingsVa, float damping);
266+
267+
native private static void setLeanSpringIntegrationCoefficient(
268+
long settingsVa, float coefficient);
269+
270+
native private static void setLeanSpringIntegrationCoefficientDecay(
271+
long settingsVa, float decay);
272+
273+
native private static void setMaxLeanAngle(long settingsVa, float angle);
99274
}

src/main/native/glue/m/MotorcycleControllerSettings.cpp

Lines changed: 151 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,154 @@ JNIEXPORT jlong JNICALL Java_com_github_stephengold_joltjni_MotorcycleController
5252
* Signature: ()J
5353
*/
5454
JNIEXPORT jlong JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_createDefault
55-
BODYOF_CREATE_DEFAULT_TARGET(MotorcycleControllerSettings)
55+
BODYOF_CREATE_DEFAULT_TARGET(MotorcycleControllerSettings)
56+
57+
/*
58+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
59+
* Method: getLeanSmoothingFactor
60+
* Signature: (J)F
61+
*/
62+
JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_getLeanSmoothingFactor
63+
(JNIEnv *, jclass, jlong settingsVa) {
64+
const MotorcycleControllerSettings * const pSettings
65+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
66+
const float result = pSettings->mLeanSmoothingFactor;
67+
return result;
68+
}
69+
70+
/*
71+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
72+
* Method: getLeanSpringConstant
73+
* Signature: (J)F
74+
*/
75+
JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_getLeanSpringConstant
76+
(JNIEnv *, jclass, jlong settingsVa) {
77+
const MotorcycleControllerSettings * const pSettings
78+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
79+
const float result = pSettings->mLeanSpringConstant;
80+
return result;
81+
}
82+
83+
/*
84+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
85+
* Method: getLeanSpringDamping
86+
* Signature: (J)F
87+
*/
88+
JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_getLeanSpringDamping
89+
(JNIEnv *, jclass, jlong settingsVa) {
90+
const MotorcycleControllerSettings * const pSettings
91+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
92+
const float result = pSettings->mLeanSpringDamping;
93+
return result;
94+
}
95+
96+
/*
97+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
98+
* Method: getLeanSpringIntegrationCoefficient
99+
* Signature: (J)F
100+
*/
101+
JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_getLeanSpringIntegrationCoefficient
102+
(JNIEnv *, jclass, jlong settingsVa) {
103+
const MotorcycleControllerSettings * const pSettings
104+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
105+
const float result = pSettings->mLeanSpringIntegrationCoefficient;
106+
return result;
107+
}
108+
109+
/*
110+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
111+
* Method: getLeanSpringIntegrationCoefficientDecay
112+
* Signature: (J)F
113+
*/
114+
JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_getLeanSpringIntegrationCoefficientDecay
115+
(JNIEnv *, jclass, jlong settingsVa) {
116+
const MotorcycleControllerSettings * const pSettings
117+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
118+
const float result = pSettings->mLeanSpringIntegrationCoefficientDecay;
119+
return result;
120+
}
121+
122+
/*
123+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
124+
* Method: getMaxLeanAngle
125+
* Signature: (J)F
126+
*/
127+
JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_getMaxLeanAngle
128+
(JNIEnv *, jclass, jlong settingsVa) {
129+
const MotorcycleControllerSettings * const pSettings
130+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
131+
const float result = pSettings->mMaxLeanAngle;
132+
return result;
133+
}
134+
135+
/*
136+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
137+
* Method: setLeanSmoothingFactor
138+
* Signature: (JF)V
139+
*/
140+
JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_setLeanSmoothingFactor
141+
(JNIEnv *, jclass, jlong settingsVa, jfloat factor) {
142+
MotorcycleControllerSettings * const pSettings
143+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
144+
pSettings->mLeanSmoothingFactor = factor;
145+
}
146+
147+
/*
148+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
149+
* Method: setLeanSpringConstant
150+
* Signature: (JF)V
151+
*/
152+
JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_setLeanSpringConstant
153+
(JNIEnv *, jclass, jlong settingsVa, jfloat k) {
154+
MotorcycleControllerSettings * const pSettings
155+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
156+
pSettings->mLeanSpringConstant = k;
157+
}
158+
159+
/*
160+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
161+
* Method: setLeanSpringDamping
162+
* Signature: (JF)V
163+
*/
164+
JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_setLeanSpringDamping
165+
(JNIEnv *, jclass, jlong settingsVa, jfloat damping) {
166+
MotorcycleControllerSettings * const pSettings
167+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
168+
pSettings->mLeanSpringDamping = damping;
169+
}
170+
171+
/*
172+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
173+
* Method: setLeanSpringIntegrationCoefficient
174+
* Signature: (JF)V
175+
*/
176+
JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_setLeanSpringIntegrationCoefficient
177+
(JNIEnv *, jclass, jlong settingsVa, jfloat coefficient) {
178+
MotorcycleControllerSettings * const pSettings
179+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
180+
pSettings->mLeanSpringIntegrationCoefficient = coefficient;
181+
}
182+
183+
/*
184+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
185+
* Method: setLeanSpringIntegrationCoefficientDecay
186+
* Signature: (JF)V
187+
*/
188+
JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_setLeanSpringIntegrationCoefficientDecay
189+
(JNIEnv *, jclass, jlong settingsVa, jfloat decay) {
190+
MotorcycleControllerSettings * const pSettings
191+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
192+
pSettings->mLeanSpringIntegrationCoefficientDecay = decay;
193+
}
194+
195+
/*
196+
* Class: com_github_stephengold_joltjni_MotorcycleControllerSettings
197+
* Method: setMaxLeanAngle
198+
* Signature: (JF)V
199+
*/
200+
JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_MotorcycleControllerSettings_setMaxLeanAngle
201+
(JNIEnv *, jclass, jlong settingsVa, jfloat angle) {
202+
MotorcycleControllerSettings * const pSettings
203+
= reinterpret_cast<MotorcycleControllerSettings *> (settingsVa);
204+
pSettings->mMaxLeanAngle = angle;
205+
}

0 commit comments

Comments
 (0)