Fix roof bug

This commit is contained in:
Miloslav Ciz 2025-06-02 15:12:17 +02:00
parent 0f0e4f4889
commit a199a84d31
2 changed files with 26 additions and 0 deletions

1
data
View file

@ -140,5 +140,6 @@ details
#RLCtiny2 00'05'181;00LCtiny2;833ee4b2 0000157:0011:0320:0034:00a0:00d4:00f0 #RLCtiny2 00'05'181;00LCtiny2;833ee4b2 0000157:0011:0320:0034:00a0:00d4:00f0
#RLCtiny3 00'11'880;00LCtiny3;df0bd8ce 0000360:0001:00c3:0031:00d3:0031:00e9:0031:00e9:0041:0069:0021:0059:0021:00c3:0041:0233:0041:0159:0251:0113:0031:01a3:0031:0143:0021:00a9:0021:00d3:0041:0253:0031:00a3:0041 #RLCtiny3 00'11'880;00LCtiny3;df0bd8ce 0000360:0001:00c3:0031:00d3:0031:00e9:0031:00e9:0041:0069:0021:0059:0021:00c3:0041:0233:0041:0159:0251:0113:0031:01a3:0031:0143:0021:00a9:0021:00d3:0041:0253:0031:00a3:0041
#RLCtiny4 00'05'280;00LCtiny4;f999f0ec 0000160:0003:01d1:0019:01f1:0119:0061:0109:0041:0209:0041 #RLCtiny4 00'05'280;00LCtiny4;f999f0ec 0000160:0003:01d1:0019:01f1:0119:0061:0109:0041:0209:0041
#RLCtiny5 00'08'811;00LCtiny5;5c14d8b6 0000267:0001:00f9:0041:0139:00b1:0109:0041:0049:0021:0103:0151:0083:0061:0069:0081:0093:0031:0083:00d1:0083:0031:0143:0021:0175:0021:0109:0031
#RLCbonus1 00'14'256;00LCbonus1;999b1acd 0000432:0001:0129:0051:0059:0011:00d3:0021:0169:0081:0013:0121:0049:0051:0033:0031:0093:0091:00c9:01f1:00c9:0061:0153:0031:0189:00c1:00e9:0021:01d9:0031:0159:0028:0020:0014:003c:0014:0020:0028:0059:0061:0079:0021:0049:00a1:0089:0041:0029:0031:0089:0011:0079:0068:0020:0038:0020:0028:0099:0041:0083 #RLCbonus1 00'14'256;00LCbonus1;999b1acd 0000432:0001:0129:0051:0059:0011:00d3:0021:0169:0081:0013:0121:0049:0051:0033:0031:0093:0091:00c9:01f1:00c9:0061:0153:0031:0189:00c1:00e9:0021:01d9:0031:0159:0028:0020:0014:003c:0014:0020:0028:0059:0061:0079:0021:0049:00a1:0089:0041:0029:0031:0089:0011:0079:0068:0020:0038:0020:0028:0099:0041:0083
#RLCbonus2 00'26'103;00LCbonus2;288d28fe 0000791:0001:0163:0101:0053:0021:00c3:0071:0063:0031:0059:00b8:0050:0034:0016:00f4:003c:00a4:00a6:0044:0056:0024:00a6:0112:0020:0029:0071:00d9:0031:0053:0091:0113:0061:00b5:0049:0101:00a3:00c2:0083:0101:0029:0051:0183:0041:0063:0041:00c3:0041:0119:0051:0019:0041:0055:0049:0018:0099:0031:0052:0023:0022:0023:0052:0073:0041:0070:0032:0046:00e4:0010:0038:0069:00a8:0139:0078:0079:00ac:0014:006c:0078:0010:0061:0079:00a1:0063:0031:0133:0031:0030:0058:002c:0018:0190:0022:0026:0030:0062:0010:0028:0029:0121:0043:0062:0020:0042:0053:00b1:0175:004c:0018:0080:0061:0033:0031:0022:0093:0011:0020:0018:0069 #RLCbonus2 00'26'103;00LCbonus2;288d28fe 0000791:0001:0163:0101:0053:0021:00c3:0071:0063:0031:0059:00b8:0050:0034:0016:00f4:003c:00a4:00a6:0044:0056:0024:00a6:0112:0020:0029:0071:00d9:0031:0053:0091:0113:0061:00b5:0049:0101:00a3:00c2:0083:0101:0029:0051:0183:0041:0063:0041:00c3:0041:0119:0051:0019:0041:0055:0049:0018:0099:0031:0052:0023:0022:0023:0052:0073:0041:0070:0032:0046:00e4:0010:0038:0069:00a8:0139:0078:0079:00ac:0014:006c:0078:0010:0061:0079:00a1:0063:0031:0133:0031:0030:0058:002c:0018:0190:0022:0026:0030:0062:0010:0028:0029:0121:0043:0062:0020:0042:0053:00b1:0175:004c:0018:0080:0061:0033:0031:0022:0093:0011:0020:0018:0069

View file

@ -39,6 +39,15 @@
will stop being compatible. It's still possible to make other changes to will stop being compatible. It's still possible to make other changes to
this module (such as optimizations or comments) without having to change this module (such as optimizations or comments) without having to change
physics version. physics version.
- The physics car body has joints numbered like this:
front
l (2)---(3) r
e |\ /| i
f | (4) | g
t |/ \| h
(0)---(1) t
rear
*/ */
typedef int32_t LCR_GameUnit; ///< abstract game unit typedef int32_t LCR_GameUnit; ///< abstract game unit
@ -1147,6 +1156,22 @@ int _LCR_racingCarShapeOK(void)
TPE_Unit bodyTension = 0; TPE_Unit bodyTension = 0;
TPE_Connection *c = LCR_racing.carConnections; TPE_Connection *c = LCR_racing.carConnections;
if (TPE_vec3Dot( // checks if roof is on the correct side (can be pushed down)
TPE_vec3Minus(
LCR_racing.carBody.joints[4].position,
LCR_racing.carBody.joints[0].position),
TPE_vec3Cross(
TPE_vec3Minus(
LCR_racing.carBody.joints[0].position,
LCR_racing.carBody.joints[2].position),
TPE_vec3Minus(
LCR_racing.carBody.joints[0].position,
LCR_racing.carBody.joints[1].position))) <= 0)
{
LCR_LOG1("roof flipped over");
return 0;
}
for (int i = 0; i < LCR_CAR_CONNECTIONS; ++i) // joint tension for (int i = 0; i < LCR_CAR_CONNECTIONS; ++i) // joint tension
{ {
bodyTension += TPE_abs( bodyTension += TPE_abs(