mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Updated box2d from 2.2.1 to 2.3.0
--HG-- branch : box2d-2.3
This commit is contained in:
@@ -19,8 +19,7 @@
|
||||
#include <Box2D/Collision/Shapes/b2ChainShape.h>
|
||||
#include <Box2D/Collision/Shapes/b2EdgeShape.h>
|
||||
#include <new>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
#include <memory.h>
|
||||
|
||||
b2ChainShape::~b2ChainShape()
|
||||
{
|
||||
@@ -33,6 +32,14 @@ void b2ChainShape::CreateLoop(const b2Vec2* vertices, int32 count)
|
||||
{
|
||||
b2Assert(m_vertices == NULL && m_count == 0);
|
||||
b2Assert(count >= 3);
|
||||
for (int32 i = 1; i < count; ++i)
|
||||
{
|
||||
b2Vec2 v1 = vertices[i-1];
|
||||
b2Vec2 v2 = vertices[i];
|
||||
// If the code crashes here, it means your vertices are too close together.
|
||||
b2Assert(b2DistanceSquared(v1, v2) > b2_linearSlop * b2_linearSlop);
|
||||
}
|
||||
|
||||
m_count = count + 1;
|
||||
m_vertices = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2));
|
||||
memcpy(m_vertices, vertices, count * sizeof(b2Vec2));
|
||||
@@ -47,11 +54,23 @@ void b2ChainShape::CreateChain(const b2Vec2* vertices, int32 count)
|
||||
{
|
||||
b2Assert(m_vertices == NULL && m_count == 0);
|
||||
b2Assert(count >= 2);
|
||||
for (int32 i = 1; i < count; ++i)
|
||||
{
|
||||
b2Vec2 v1 = vertices[i-1];
|
||||
b2Vec2 v2 = vertices[i];
|
||||
// If the code crashes here, it means your vertices are too close together.
|
||||
b2Assert(b2DistanceSquared(v1, v2) > b2_linearSlop * b2_linearSlop);
|
||||
}
|
||||
|
||||
m_count = count;
|
||||
m_vertices = (b2Vec2*)b2Alloc(count * sizeof(b2Vec2));
|
||||
memcpy(m_vertices, vertices, m_count * sizeof(b2Vec2));
|
||||
|
||||
m_hasPrevVertex = false;
|
||||
m_hasNextVertex = false;
|
||||
|
||||
m_prevVertex.SetZero();
|
||||
m_nextVertex.SetZero();
|
||||
}
|
||||
|
||||
void b2ChainShape::SetPrevVertex(const b2Vec2& prevVertex)
|
||||
|
||||
Reference in New Issue
Block a user