mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Updated box2d from 2.2.1 to 2.3.0
--HG-- branch : box2d-2.3
This commit is contained in:
@@ -21,13 +21,15 @@
|
||||
#include <Box2D/Collision/b2TimeOfImpact.h>
|
||||
#include <Box2D/Collision/Shapes/b2CircleShape.h>
|
||||
#include <Box2D/Collision/Shapes/b2PolygonShape.h>
|
||||
#include <Box2D/Common/b2Timer.h>
|
||||
|
||||
#include <cstdio>
|
||||
using namespace std;
|
||||
#include <stdio.h>
|
||||
|
||||
float32 b2_toiTime, b2_toiMaxTime;
|
||||
int32 b2_toiCalls, b2_toiIters, b2_toiMaxIters;
|
||||
int32 b2_toiRootIters, b2_toiMaxRootIters;
|
||||
|
||||
//
|
||||
struct b2SeparationFunction
|
||||
{
|
||||
enum Type
|
||||
@@ -119,6 +121,7 @@ struct b2SeparationFunction
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
float32 FindMinSeparation(int32* indexA, int32* indexB, float32 t) const
|
||||
{
|
||||
b2Transform xfA, xfB;
|
||||
@@ -187,6 +190,7 @@ struct b2SeparationFunction
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
float32 Evaluate(int32 indexA, int32 indexB, float32 t) const
|
||||
{
|
||||
b2Transform xfA, xfB;
|
||||
@@ -197,9 +201,6 @@ struct b2SeparationFunction
|
||||
{
|
||||
case e_points:
|
||||
{
|
||||
b2Vec2 axisA = b2MulT(xfA.q, m_axis);
|
||||
b2Vec2 axisB = b2MulT(xfB.q, -m_axis);
|
||||
|
||||
b2Vec2 localPointA = m_proxyA->GetVertex(indexA);
|
||||
b2Vec2 localPointB = m_proxyB->GetVertex(indexB);
|
||||
|
||||
@@ -215,8 +216,6 @@ struct b2SeparationFunction
|
||||
b2Vec2 normal = b2Mul(xfA.q, m_axis);
|
||||
b2Vec2 pointA = b2Mul(xfA, m_localPoint);
|
||||
|
||||
b2Vec2 axisB = b2MulT(xfB.q, -normal);
|
||||
|
||||
b2Vec2 localPointB = m_proxyB->GetVertex(indexB);
|
||||
b2Vec2 pointB = b2Mul(xfB, localPointB);
|
||||
|
||||
@@ -229,8 +228,6 @@ struct b2SeparationFunction
|
||||
b2Vec2 normal = b2Mul(xfB.q, m_axis);
|
||||
b2Vec2 pointB = b2Mul(xfB, m_localPoint);
|
||||
|
||||
b2Vec2 axisA = b2MulT(xfA.q, -normal);
|
||||
|
||||
b2Vec2 localPointA = m_proxyA->GetVertex(indexA);
|
||||
b2Vec2 pointA = b2Mul(xfA, localPointA);
|
||||
|
||||
@@ -256,6 +253,8 @@ struct b2SeparationFunction
|
||||
// by computing the largest time at which separation is maintained.
|
||||
void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input)
|
||||
{
|
||||
b2Timer timer;
|
||||
|
||||
++b2_toiCalls;
|
||||
|
||||
output->state = b2TOIOutput::e_unknown;
|
||||
@@ -422,6 +421,9 @@ void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input)
|
||||
t = 0.5f * (a1 + a2);
|
||||
}
|
||||
|
||||
++rootIterCount;
|
||||
++b2_toiRootIters;
|
||||
|
||||
float32 s = fcn.Evaluate(indexA, indexB, t);
|
||||
|
||||
if (b2Abs(s - target) < tolerance)
|
||||
@@ -442,10 +444,7 @@ void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input)
|
||||
a2 = t;
|
||||
s2 = s;
|
||||
}
|
||||
|
||||
++rootIterCount;
|
||||
++b2_toiRootIters;
|
||||
|
||||
|
||||
if (rootIterCount == 50)
|
||||
{
|
||||
break;
|
||||
@@ -480,4 +479,8 @@ void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input)
|
||||
}
|
||||
|
||||
b2_toiMaxIters = b2Max(b2_toiMaxIters, iter);
|
||||
|
||||
float32 time = timer.GetMilliseconds();
|
||||
b2_toiMaxTime = b2Max(b2_toiMaxTime, time);
|
||||
b2_toiTime += time;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user