Handle start position

This commit is contained in:
Miloslav Ciz 2024-09-29 20:52:52 +02:00
parent 34293981b0
commit beda272f18
4 changed files with 146 additions and 162 deletions

View file

@ -252,6 +252,9 @@ typedef struct
energy. */
#define TPE_BODY_FLAG_NO_BSPHERE 64 /**< Stops quick bounding sphere checks
against environment. */
#define TPE_BODY_FLAG_UNRESOLVED 128 /**< Set automatically for bodies whose
collision with environment failed
to be resolved. */
/** Function used for defining static environment, working similarly to an SDF
(signed distance function). The parameters are: 3D point P, max distance D.
@ -1913,6 +1916,8 @@ uint8_t TPE_bodyEnvironmentResolveCollision(TPE_Body *body,
TPE_Vec3 c;
TPE_Unit d;
body->flags &= ~TPE_BODY_FLAG_UNRESOLVED;
if (!(body->flags & TPE_BODY_FLAG_NO_BSPHERE))
{
TPE_bodyGetFastBSphere(body,&c,&d);
@ -1938,6 +1943,9 @@ uint8_t TPE_bodyEnvironmentResolveCollision(TPE_Body *body,
{
collision = 1;
if (r == 2)
body->flags |= TPE_BODY_FLAG_UNRESOLVED;
if (body->flags & TPE_BODY_FLAG_NONROTATING)
_TPE_bodyNonrotatingJointCollided(body,i,previousPos,r == 1);
}