reworked overlap range so that it now detects 'inverse' collisions
This commit is contained in:
		
							parent
							
								
									f5a9b3e8c6
								
							
						
					
					
						commit
						22709234cd
					
				|  | @ -42,11 +42,13 @@ Vector _internal_collision_overlap_on_axis(PhysicsEntity self, PhysicsEntity oth | |||
|     if(a_range.min <= b_range.max && a_range.min <= b_range.max) { | ||||
|         const float overlap_left = a_range.max - b_range.min; | ||||
|         const float overlap_right = b_range.min - a_range.max; | ||||
|     const float overlap_left = a_range.max - b_range.min; | ||||
|     const float overlap_right = b_range.min - a_range.max; | ||||
|     *out_point = fabsf(overlap_right) <= fabsf(overlap_left) ? a_range.maxpoint : a_range.minpoint; | ||||
|     if(a_range.min <= b_range.max && b_range.min <= a_range.max) { | ||||
|         const float shortest = fminf(overlap_left, overlap_right); | ||||
|         *out_point = overlap_right < overlap_left ? a_range.maxpoint : a_range.minpoint; | ||||
|         return vmulff(axis, shortest); | ||||
|     } else { | ||||
|         *out_point = InfinityVector; | ||||
|         return ZeroVector; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -18,6 +18,7 @@ typedef struct Collision { | |||
|     Vector edge_right; | ||||
| } Collision; | ||||
| 
 | ||||
| extern Collision collision_invert(Collision src, PhysicsEntity new_other); | ||||
| extern int collision_check(PhysicsEntity a, PhysicsEntity b, Collision* out_a, Collision* out_b); | ||||
| 
 | ||||
| #endif // !_fencer_collision_h
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Sara
						Sara