Start block collisions

This commit is contained in:
Miloslav Ciz 2024-09-23 20:21:08 +02:00
parent c0aa81e79e
commit e068b02b9f
5 changed files with 159 additions and 11 deletions

View file

@ -250,6 +250,8 @@ typedef struct
performance. */
#define TPE_BODY_FLAG_ALWAYS_ACTIVE 32 /**< Will never deactivate due to low
energy. */
#define TPE_BODY_FLAG_NO_BSPHERE 64 /**< Stops quick bounding sphere checks
against environment. */
/** Function used for defining static environment, working similarly to an SDF
(signed distance function). The parameters are: 3D point P, max distance D.
@ -1911,10 +1913,13 @@ uint8_t TPE_bodyEnvironmentResolveCollision(TPE_Body *body,
TPE_Vec3 c;
TPE_Unit d;
TPE_bodyGetFastBSphere(body,&c,&d);
if (!(body->flags & TPE_BODY_FLAG_NO_BSPHERE))
{
TPE_bodyGetFastBSphere(body,&c,&d);
if (TPE_DISTANCE(c,env(c,d)) > d)
return 0;
if (TPE_DISTANCE(c,env(c,d)) > d)
return 0;
}
// now test the full body collision: