@@ -102,10 +102,12 @@ bool isOverlappingAABB(const iwEnv *e, const b2Vec2 pos, const float distance, c
102102 return ctx .overlaps ;
103103}
104104
105- // TODO: store a shape proxy in entities?
106- b2ShapeProxy makeDistanceProxyFromType (const enum entityType type , bool * isCircle ) {
105+ b2ShapeProxy makeDistanceProxy (const entity * ent , bool * isCircle ) {
107106 b2ShapeProxy proxy = {0 };
108- switch (type ) {
107+ float extent = 0.0f ;
108+ wallEntity * wall = NULL ;
109+
110+ switch (ent -> type ) {
109111 case DRONE_ENTITY :
110112 * isCircle = true;
111113 proxy .count = 1 ;
@@ -116,42 +118,44 @@ b2ShapeProxy makeDistanceProxyFromType(const enum entityType type, bool *isCircl
116118 proxy .count = 1 ;
117119 proxy .radius = DRONE_SHIELD_RADIUS ;
118120 break ;
121+ case PROJECTILE_ENTITY :
122+ * isCircle = true;
123+ const projectileEntity * proj = ent -> entity ;
124+ proxy .count = 1 ;
125+ proxy .radius = proj -> weaponInfo -> radius ;
126+ break ;
119127 case WEAPON_PICKUP_ENTITY :
128+ extent = PICKUP_THICKNESS / 2.0f ;
129+
120130 proxy .count = 4 ;
121- proxy .points [0 ] = (b2Vec2 ){.x = - PICKUP_THICKNESS / 2.0f , .y = - PICKUP_THICKNESS / 2.0f };
122- proxy .points [1 ] = (b2Vec2 ){.x = - PICKUP_THICKNESS / 2.0f , .y = + PICKUP_THICKNESS / 2.0f };
123- proxy .points [2 ] = (b2Vec2 ){.x = + PICKUP_THICKNESS / 2.0f , .y = - PICKUP_THICKNESS / 2.0f };
124- proxy .points [3 ] = (b2Vec2 ){.x = + PICKUP_THICKNESS / 2.0f , .y = + PICKUP_THICKNESS / 2.0f };
131+ proxy .points [0 ] = (b2Vec2 ){.x = - extent , .y = - extent };
132+ proxy .points [1 ] = (b2Vec2 ){.x = - extent , .y = + extent };
133+ proxy .points [2 ] = (b2Vec2 ){.x = + extent , .y = - extent };
134+ proxy .points [3 ] = (b2Vec2 ){.x = + extent , .y = + extent };
125135 break ;
126136 case STANDARD_WALL_ENTITY :
127137 case BOUNCY_WALL_ENTITY :
128138 case DEATH_WALL_ENTITY :
139+ extent = WALL_THICKNESS ;
140+ wall = ent -> entity ;
141+ if (wall -> isFloating ) {
142+ extent = FLOATING_WALL_THICKNESS ;
143+ }
144+ extent /= 2.0f ;
145+
129146 proxy .count = 4 ;
130- proxy .points [0 ] = (b2Vec2 ){.x = - FLOATING_WALL_THICKNESS / 2.0f , .y = - FLOATING_WALL_THICKNESS / 2.0f };
131- proxy .points [1 ] = (b2Vec2 ){.x = - FLOATING_WALL_THICKNESS / 2.0f , .y = + FLOATING_WALL_THICKNESS / 2.0f };
132- proxy .points [2 ] = (b2Vec2 ){.x = + FLOATING_WALL_THICKNESS / 2.0f , .y = - FLOATING_WALL_THICKNESS / 2.0f };
133- proxy .points [3 ] = (b2Vec2 ){.x = + FLOATING_WALL_THICKNESS / 2.0f , .y = + FLOATING_WALL_THICKNESS / 2.0f };
147+ proxy .points [0 ] = (b2Vec2 ){.x = - extent , .y = - extent };
148+ proxy .points [1 ] = (b2Vec2 ){.x = - extent , .y = + extent };
149+ proxy .points [2 ] = (b2Vec2 ){.x = + extent , .y = - extent };
150+ proxy .points [3 ] = (b2Vec2 ){.x = + extent , .y = + extent };
134151 break ;
135152 default :
136- ERRORF ("unknown entity type for shape distance: %d" , type );
153+ ERRORF ("unknown entity type for shape distance: %d" , ent -> type );
137154 }
138155
139156 return proxy ;
140157}
141158
142- b2ShapeProxy makeDistanceProxy (const entity * ent , bool * isCircle ) {
143- if (ent -> type == PROJECTILE_ENTITY ) {
144- * isCircle = true;
145- b2ShapeProxy proxy = {0 };
146- const projectileEntity * proj = ent -> entity ;
147- proxy .count = 1 ;
148- proxy .radius = proj -> weaponInfo -> radius ;
149- return proxy ;
150- }
151-
152- return makeDistanceProxyFromType (ent -> type , isCircle );
153- }
154-
155159b2Transform entityTransform (const entity * ent ) {
156160 b2Transform transform ;
157161 wallEntity * wall ;
@@ -1357,6 +1361,7 @@ bool explodeCallback(b2ShapeId shapeID, void *context) {
13571361
13581362 b2SimplexCache cache = {0 };
13591363 const b2DistanceOutput output = b2ShapeDistance (& input , & cache , NULL , 0 );
1364+
13601365 if (output .distance > ctx -> def -> radius ) {
13611366 return true;
13621367 }
@@ -1981,6 +1986,7 @@ void droneBurst(iwEnv *e, droneEntity *drone) {
19811986 b2ExplosionDef explosion = {
19821987 .position = drone -> pos ,
19831988 .radius = radius ,
1989+ .falloff = 0.0f ,
19841990 .impulsePerLength = (DRONE_BURST_IMPACT_BASE * drone -> burstCharge ) + DRONE_BURST_IMPACT_MIN ,
19851991 .maskBits = WALL_SHAPE | FLOATING_WALL_SHAPE | PROJECTILE_SHAPE | DRONE_SHAPE ,
19861992 };
0 commit comments