Fiddle with physics again
This commit is contained in:
parent
a9c8bd1c4b
commit
68df5326d7
2 changed files with 37 additions and 8 deletions
1
TODO.txt
1
TODO.txt
|
@ -2,6 +2,7 @@ fuck issue trackers :D
|
||||||
|
|
||||||
=========== GENERAL ==============
|
=========== GENERAL ==============
|
||||||
|
|
||||||
|
- LOD blocks in lower res look too small
|
||||||
- hitting ramps at higher speed still often bugs, try to fiddle with physics
|
- hitting ramps at higher speed still often bugs, try to fiddle with physics
|
||||||
again (reshape iterations, tension, ...)
|
again (reshape iterations, tension, ...)
|
||||||
- make replays have better names (time etc.)
|
- make replays have better names (time etc.)
|
||||||
|
|
44
racing.h
44
racing.h
|
@ -61,12 +61,16 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
|
||||||
#define LCR_RACING_EVENT_FAN 0x0020
|
#define LCR_RACING_EVENT_FAN 0x0020
|
||||||
|
|
||||||
#define LCR_PHYSICS_UNIT 4096 ///< len. of square for phys. engine
|
#define LCR_PHYSICS_UNIT 4096 ///< len. of square for phys. engine
|
||||||
|
|
||||||
#define TPE_RESHAPE_TENSION_LIMIT 8
|
/* The combination of values TPE_RESHAPE_TENSION_LIMIT and
|
||||||
#define TPE_RESHAPE_ITERATIONS 16 /**< Empirically tested, seems to have a
|
TPE_RESHAPE_ITERATIONS has crucial effect on the bugginess and feel of car
|
||||||
big impact on bugs that happen when
|
physics, especially when driving onto ramps in high speed etc., the values
|
||||||
driving onto a curved ramp under
|
were chosen empirically by testing, these are the ones that showed to
|
||||||
various angles. */
|
subjectively feel the best. */
|
||||||
|
|
||||||
|
#define TPE_RESHAPE_TENSION_LIMIT 7
|
||||||
|
#define TPE_RESHAPE_ITERATIONS 18
|
||||||
|
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "tinyphysicsengine.h"
|
#include "tinyphysicsengine.h"
|
||||||
|
@ -1504,8 +1508,31 @@ uint32_t LCR_racingStep(unsigned int input)
|
||||||
|
|
||||||
TPE_worldStep(&(LCR_racing.physicsWorld)); // normal step
|
TPE_worldStep(&(LCR_racing.physicsWorld)); // normal step
|
||||||
|
|
||||||
if ((LCR_racing.carBody.flags & TPE_BODY_FLAG_UNRESOLVED) ||
|
uint8_t useSimplified = (LCR_racing.carBody.flags &
|
||||||
!_LCR_racingCarShapeOK()) // bad?
|
TPE_BODY_FLAG_UNRESOLVED) != 0;
|
||||||
|
|
||||||
|
if (!useSimplified && !_LCR_racingCarShapeOK())
|
||||||
|
{
|
||||||
|
useSimplified = 1;
|
||||||
|
|
||||||
|
// we only do this with wheels on ground, because squeezed roof bugs here
|
||||||
|
if ((LCR_racing.wheelCollisions & 0x0f) == 0x0f)
|
||||||
|
for (int i = 0; i < 4 * TPE_RESHAPE_ITERATIONS; ++i)
|
||||||
|
{
|
||||||
|
LCR_LOG2("trying harder to resolve physics");
|
||||||
|
|
||||||
|
TPE_bodyReshape(&LCR_racing.carBody,_LCR_racingEnvironmentFunction);
|
||||||
|
|
||||||
|
if ((i % 4 == 0) && _LCR_racingCarShapeOK())
|
||||||
|
{
|
||||||
|
LCR_LOG2("succeeded in fixing physics");
|
||||||
|
useSimplified = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useSimplified)
|
||||||
{
|
{
|
||||||
LCR_LOG2("using simplified physics");
|
LCR_LOG2("using simplified physics");
|
||||||
|
|
||||||
|
@ -1555,6 +1582,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accelerate roof and wheels away from each other:
|
// Accelerate roof and wheels away from each other:
|
||||||
|
|
||||||
for (int i = 0; i < LCR_CAR_JOINTS; ++i)
|
for (int i = 0; i < LCR_CAR_JOINTS; ++i)
|
||||||
{
|
{
|
||||||
LCR_racing.carBody.joints[i].velocity[0] += (i == 4 ? 1 : -1) * tmpVec.x;
|
LCR_racing.carBody.joints[i].velocity[0] += (i == 4 ? 1 : -1) * tmpVec.x;
|
||||||
|
|
Loading…
Reference in a new issue