Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t_min := +∞
- t_max := -∞
- foreach axis in potential_separating_axes
- a_min := +∞
- a_max := -∞
- foreach vertex in a.vertices
- a_min = min(a_min, vertex · axis)
- a_max = max(a_max, vertex · axis)
- b_min := +∞
- b_max := -∞
- foreach vertex in b.vertices
- b_min = min(b_min, vertex · axis)
- b_max = max(b_max, vertex · axis)
- v := b.velocity · axis
- if v > 0 then
- if a_max < b_min then
- return no_intersection
- else if (a_min < b_min < a_max) or (b_min < a_min < b_max) then
- t_min = min(t_min, (a_max - b_min) / v)
- t_max = max(t_max, 0)
- else
- t_min = min(t_min, (a_max - b_min) / v)
- t_max = max(t_max, (a_min - b_max) / v)
- else if v < 0 then
- // repeat the above case with a and b swapped
- else if v = 0 then
- if a_min < b_max and b_min < a_max then
- t_min = min(t_min, 0)
- t_max = max(t_max, 0)
- else
- return no_intersection
- if t_max < t_min then
- // advance b by b.velocity * t_max
- return intersection
- else
- return no_intersection
- vec3 vertex;
- float mindot = FLT_MAX;
- for ( vert : vertices )
- {
- if (dot(vert, MTV) < mindot)
- {
- mindot = dot(vert, MTV);
- vertex = vert;
- }
- }
- halfstep = 1.0f;
- vec3 cp = vertex;
- vec3 v = A.velocity*framedurationSeconds;
- float errorThreshold = 0.01f; //choose meaningful value here
- while (abs(dot(cp,normal)) > errorThreshold)
- {
- v*=-1*(halfstep*0.5f);
- cp += v;
- }
- return cp;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement