Commit a0517724 authored by Frederik Schwarzer's avatar Frederik Schwarzer

Pull in new Version of Box2D.

Source: https://github.com/erincatto/Box2D.git
Revision: 6a69ddbbd5

Applied a dos2unix run to switch to unix line endings.
parent 3e0cfc90
/*
* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BOX2D_H
#define BOX2D_H
/**
\mainpage Box2D API Documentation
\section intro_sec Getting Started
For documentation please see http://box2d.org/documentation.html
For discussion please visit http://box2d.org/forum
*/
// These include files constitute the main Box2D API
#include <Box2D/Common/b2Settings.h>
#include <Box2D/Common/b2Draw.h>
#include <Box2D/Common/b2Timer.h>
#include <Box2D/Collision/Shapes/b2CircleShape.h>
#include <Box2D/Collision/Shapes/b2EdgeShape.h>
#include <Box2D/Collision/Shapes/b2ChainShape.h>
#include <Box2D/Collision/Shapes/b2PolygonShape.h>
#include <Box2D/Collision/b2BroadPhase.h>
#include <Box2D/Collision/b2Distance.h>
#include <Box2D/Collision/b2DynamicTree.h>
#include <Box2D/Collision/b2TimeOfImpact.h>
#include <Box2D/Dynamics/b2Body.h>
#include <Box2D/Dynamics/b2Fixture.h>
#include <Box2D/Dynamics/b2WorldCallbacks.h>
#include <Box2D/Dynamics/b2TimeStep.h>
#include <Box2D/Dynamics/b2World.h>
#include <Box2D/Dynamics/Contacts/b2Contact.h>
#include <Box2D/Dynamics/Joints/b2DistanceJoint.h>
#include <Box2D/Dynamics/Joints/b2FrictionJoint.h>
#include <Box2D/Dynamics/Joints/b2GearJoint.h>
#include <Box2D/Dynamics/Joints/b2MotorJoint.h>
#include <Box2D/Dynamics/Joints/b2MouseJoint.h>
#include <Box2D/Dynamics/Joints/b2PrismaticJoint.h>
#include <Box2D/Dynamics/Joints/b2PulleyJoint.h>
#include <Box2D/Dynamics/Joints/b2RevoluteJoint.h>
#include <Box2D/Dynamics/Joints/b2RopeJoint.h>
#include <Box2D/Dynamics/Joints/b2WeldJoint.h>
#include <Box2D/Dynamics/Joints/b2WheelJoint.h>
#endif
# -*- cmake -*-
#
# Box2dConfig.cmake(.in)
#
# Use the following variables to compile and link against Box2d:
# BOX2D_FOUND - True if Box2d was found on your system
# BOX2D_USE_FILE - The file making Box2d usable
# BOX2D_DEFINITIONS - Definitions needed to build with Box2d
# BOX2D_INCLUDE_DIR - Box2d headers location
# BOX2D_INCLUDE_DIRS - List of directories where Box2d header file are
# BOX2D_LIBRARY - Library name
# BOX2D_LIBRARIES - List of libraries to link against
# BOX2D_LIBRARY_DIRS - List of directories containing Box2d libraries
# BOX2D_ROOT_DIR - The base directory of Box2d
# BOX2D_VERSION_STRING - A human-readable string containing the version
set ( BOX2D_FOUND 1 )
set ( BOX2D_USE_FILE "@BOX2D_USE_FILE@" )
set ( BOX2D_DEFINITIONS "@BOX2D_DEFINITIONS@" )
set ( BOX2D_INCLUDE_DIR "@BOX2D_INCLUDE_DIR@" )
set ( Box2D_INCLUDE_DIRS "@BOX2D_INCLUDE_DIRS@" ) # deprecated
set ( BOX2D_INCLUDE_DIRS "@BOX2D_INCLUDE_DIRS@" )
set ( BOX2D_LIBRARY "@BOX2D_LIBRARY@" )
set ( BOX2D_LIBRARIES "@BOX2D_LIBRARIES@" )
set ( BOX2D_LIBRARY_DIRS "@BOX2D_LIBRARY_DIRS@" )
set ( BOX2D_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" )
set ( BOX2D_VERSION_STRING "@BOX2D_VERSION@" )
set(BOX2D_Collision_SRCS
Collision/b2BroadPhase.cpp
Collision/b2CollideCircle.cpp
Collision/b2CollideEdge.cpp
Collision/b2CollidePolygon.cpp
Collision/b2Collision.cpp
Collision/b2Distance.cpp
Collision/b2DynamicTree.cpp
Collision/b2TimeOfImpact.cpp
)
set(BOX2D_Collision_HDRS
Collision/b2BroadPhase.h
Collision/b2Collision.h
Collision/b2Distance.h
Collision/b2DynamicTree.h
Collision/b2TimeOfImpact.h
)
set(BOX2D_Shapes_SRCS
Collision/Shapes/b2CircleShape.cpp
Collision/Shapes/b2EdgeShape.cpp
Collision/Shapes/b2ChainShape.cpp
Collision/Shapes/b2PolygonShape.cpp
)
set(BOX2D_Shapes_HDRS
Collision/Shapes/b2CircleShape.h
Collision/Shapes/b2EdgeShape.h
Collision/Shapes/b2ChainShape.h
Collision/Shapes/b2PolygonShape.h
Collision/Shapes/b2Shape.h
)
set(BOX2D_Common_SRCS
Common/b2BlockAllocator.cpp
Common/b2Draw.cpp
Common/b2Math.cpp
Common/b2Settings.cpp
Common/b2StackAllocator.cpp
Common/b2Timer.cpp
)
set(BOX2D_Common_HDRS
Common/b2BlockAllocator.h
Common/b2Draw.h
Common/b2GrowableStack.h
Common/b2Math.h
Common/b2Settings.h
Common/b2StackAllocator.h
Common/b2Timer.h
)
set(BOX2D_Dynamics_SRCS
Dynamics/b2Body.cpp
Dynamics/b2ContactManager.cpp
Dynamics/b2Fixture.cpp
Dynamics/b2Island.cpp
Dynamics/b2World.cpp
Dynamics/b2WorldCallbacks.cpp
)
set(BOX2D_Dynamics_HDRS
Dynamics/b2Body.h
Dynamics/b2ContactManager.h
Dynamics/b2Fixture.h
Dynamics/b2Island.h
Dynamics/b2TimeStep.h
Dynamics/b2World.h
Dynamics/b2WorldCallbacks.h
)
set(BOX2D_Contacts_SRCS
Dynamics/Contacts/b2CircleContact.cpp
Dynamics/Contacts/b2Contact.cpp
Dynamics/Contacts/b2ContactSolver.cpp
Dynamics/Contacts/b2PolygonAndCircleContact.cpp
Dynamics/Contacts/b2EdgeAndCircleContact.cpp
Dynamics/Contacts/b2EdgeAndPolygonContact.cpp
Dynamics/Contacts/b2ChainAndCircleContact.cpp
Dynamics/Contacts/b2ChainAndPolygonContact.cpp
Dynamics/Contacts/b2PolygonContact.cpp
)
set(BOX2D_Contacts_HDRS
Dynamics/Contacts/b2CircleContact.h
Dynamics/Contacts/b2Contact.h
Dynamics/Contacts/b2ContactSolver.h
Dynamics/Contacts/b2PolygonAndCircleContact.h
Dynamics/Contacts/b2EdgeAndCircleContact.h
Dynamics/Contacts/b2EdgeAndPolygonContact.h
Dynamics/Contacts/b2ChainAndCircleContact.h
Dynamics/Contacts/b2ChainAndPolygonContact.h
Dynamics/Contacts/b2PolygonContact.h
)
set(BOX2D_Joints_SRCS
Dynamics/Joints/b2DistanceJoint.cpp
Dynamics/Joints/b2FrictionJoint.cpp
Dynamics/Joints/b2GearJoint.cpp
Dynamics/Joints/b2Joint.cpp
Dynamics/Joints/b2MotorJoint.cpp
Dynamics/Joints/b2MouseJoint.cpp
Dynamics/Joints/b2PrismaticJoint.cpp
Dynamics/Joints/b2PulleyJoint.cpp
Dynamics/Joints/b2RevoluteJoint.cpp
Dynamics/Joints/b2RopeJoint.cpp
Dynamics/Joints/b2WeldJoint.cpp
Dynamics/Joints/b2WheelJoint.cpp
)
set(BOX2D_Joints_HDRS
Dynamics/Joints/b2DistanceJoint.h
Dynamics/Joints/b2FrictionJoint.h
Dynamics/Joints/b2GearJoint.h
Dynamics/Joints/b2Joint.h
Dynamics/Joints/b2MotorJoint.h
Dynamics/Joints/b2MouseJoint.h
Dynamics/Joints/b2PrismaticJoint.h
Dynamics/Joints/b2PulleyJoint.h
Dynamics/Joints/b2RevoluteJoint.h
Dynamics/Joints/b2RopeJoint.h
Dynamics/Joints/b2WeldJoint.h
Dynamics/Joints/b2WheelJoint.h
)
set(BOX2D_Rope_SRCS
Rope/b2Rope.cpp
)
set(BOX2D_Rope_HDRS
Rope/b2Rope.h
)
set(BOX2D_General_HDRS
Box2D.h
)
include_directories( ../ )
if(BOX2D_BUILD_SHARED)
add_library(Box2D_shared SHARED
${BOX2D_General_HDRS}
${BOX2D_Joints_SRCS}
${BOX2D_Joints_HDRS}
${BOX2D_Contacts_SRCS}
${BOX2D_Contacts_HDRS}
${BOX2D_Dynamics_SRCS}
${BOX2D_Dynamics_HDRS}
${BOX2D_Common_SRCS}
${BOX2D_Common_HDRS}
${BOX2D_Shapes_SRCS}
${BOX2D_Shapes_HDRS}
${BOX2D_Collision_SRCS}
${BOX2D_Collision_HDRS}
${BOX2D_Rope_SRCS}
${BOX2D_Rope_HDRS}
)
set_target_properties(Box2D_shared PROPERTIES
OUTPUT_NAME "Box2D"
CLEAN_DIRECT_OUTPUT 1
VERSION ${BOX2D_VERSION}
)
endif()
if(BOX2D_BUILD_STATIC)
add_library(Box2D STATIC
${BOX2D_General_HDRS}
${BOX2D_Joints_SRCS}
${BOX2D_Joints_HDRS}
${BOX2D_Contacts_SRCS}
${BOX2D_Contacts_HDRS}
${BOX2D_Dynamics_SRCS}
${BOX2D_Dynamics_HDRS}
${BOX2D_Common_SRCS}
${BOX2D_Common_HDRS}
${BOX2D_Shapes_SRCS}
${BOX2D_Shapes_HDRS}
${BOX2D_Collision_SRCS}
${BOX2D_Collision_HDRS}
${BOX2D_Rope_SRCS}
${BOX2D_Rope_HDRS}
)
set_target_properties(Box2D PROPERTIES
CLEAN_DIRECT_OUTPUT 1
VERSION ${BOX2D_VERSION}
)
endif()
# These are used to create visual studio folders.
source_group(Collision FILES ${BOX2D_Collision_SRCS} ${BOX2D_Collision_HDRS})
source_group(Collision\\Shapes FILES ${BOX2D_Shapes_SRCS} ${BOX2D_Shapes_HDRS})
source_group(Common FILES ${BOX2D_Common_SRCS} ${BOX2D_Common_HDRS})
source_group(Dynamics FILES ${BOX2D_Dynamics_SRCS} ${BOX2D_Dynamics_HDRS})
source_group(Dynamics\\Contacts FILES ${BOX2D_Contacts_SRCS} ${BOX2D_Contacts_HDRS})
source_group(Dynamics\\Joints FILES ${BOX2D_Joints_SRCS} ${BOX2D_Joints_HDRS})
source_group(Include FILES ${BOX2D_General_HDRS})
source_group(Rope FILES ${BOX2D_Rope_SRCS} ${BOX2D_Rope_HDRS})
if(BOX2D_INSTALL)
# install headers
install(FILES ${BOX2D_General_HDRS} DESTINATION include/Box2D)
install(FILES ${BOX2D_Collision_HDRS} DESTINATION include/Box2D/Collision)
install(FILES ${BOX2D_Shapes_HDRS} DESTINATION include/Box2D/Collision/Shapes)
install(FILES ${BOX2D_Common_HDRS} DESTINATION include/Box2D/Common)
install(FILES ${BOX2D_Dynamics_HDRS} DESTINATION include/Box2D/Dynamics)
install(FILES ${BOX2D_Contacts_HDRS} DESTINATION include/Box2D/Dynamics/Contacts)
install(FILES ${BOX2D_Joints_HDRS} DESTINATION include/Box2D/Dynamics/Joints)
install(FILES ${BOX2D_Rope_HDRS} DESTINATION include/Box2D/Rope)
# install libraries
if(BOX2D_BUILD_SHARED)
install(TARGETS Box2D_shared EXPORT Box2D-targets
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
RUNTIME DESTINATION bin)
endif()
if(BOX2D_BUILD_STATIC)
install(TARGETS Box2D EXPORT Box2D-targets DESTINATION ${LIB_INSTALL_DIR})
endif()
# install build system hooks for third-party apps
install(EXPORT Box2D-targets DESTINATION ${LIB_INSTALL_DIR}/Box2D)
set (BOX2D_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set (BOX2D_INCLUDE_DIRS ${BOX2D_INCLUDE_DIR} )
set (BOX2D_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR})
set (BOX2D_LIBRARY Box2D)
set (BOX2D_LIBRARIES ${BOX2D_LIBRARY})
set (BOX2D_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/cmake/Box2D/UseBox2D.cmake)
configure_file(Box2DConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/Box2DConfig.cmake @ONLY ESCAPE_QUOTES)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Box2DConfig.cmake UseBox2D.cmake DESTINATION ${LIB_INSTALL_DIR}/cmake/Box2D)
endif(BOX2D_INSTALL)
/*
* Copyright (c) 2006-2010 Erin Catto http://www.gphysics.com
* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
......@@ -16,73 +16,136 @@
* 3. This notice may not be removed or altered from any source distribution.
*/
#include <Box2D/Collision/Shapes/b2LoopShape.h>
#include <Box2D/Collision/Shapes/b2ChainShape.h>
#include <Box2D/Collision/Shapes/b2EdgeShape.h>
#include <new>
#include <cstring>
using namespace std;
#include <string.h>
b2LoopShape::~b2LoopShape()
b2ChainShape::~b2ChainShape()
{
Clear();
}
void b2ChainShape::Clear()
{
b2Free(m_vertices);
m_vertices = NULL;
m_count = 0;
}
void b2LoopShape::Create(const b2Vec2* vertices, int32 count)
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));
m_vertices[count] = m_vertices[0];
m_prevVertex = m_vertices[m_count - 2];
m_nextVertex = m_vertices[1];
m_hasPrevVertex = true;
m_hasNextVertex = true;
}
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)
{
// If the code crashes here, it means your vertices are too close together.
b2Assert(b2DistanceSquared(vertices[i-1], vertices[i]) > 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();
}
b2Shape* b2LoopShape::Clone(b2BlockAllocator* allocator) const
void b2ChainShape::SetPrevVertex(const b2Vec2& prevVertex)
{
void* mem = allocator->Allocate(sizeof(b2LoopShape));
b2LoopShape* clone = new (mem) b2LoopShape;
clone->Create(m_vertices, m_count);
m_prevVertex = prevVertex;
m_hasPrevVertex = true;
}
void b2ChainShape::SetNextVertex(const b2Vec2& nextVertex)
{
m_nextVertex = nextVertex;
m_hasNextVertex = true;
}
b2Shape* b2ChainShape::Clone(b2BlockAllocator* allocator) const
{
void* mem = allocator->Allocate(sizeof(b2ChainShape));
b2ChainShape* clone = new (mem) b2ChainShape;
clone->CreateChain(m_vertices, m_count);
clone->m_prevVertex = m_prevVertex;
clone->m_nextVertex = m_nextVertex;
clone->m_hasPrevVertex = m_hasPrevVertex;
clone->m_hasNextVertex = m_hasNextVertex;
return clone;
}
int32 b2LoopShape::GetChildCount() const
int32 b2ChainShape::GetChildCount() const
{
return m_count;
// edge count = vertex count - 1
return m_count - 1;
}
void b2LoopShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
{
b2Assert(2 <= m_count);
b2Assert(0 <= index && index < m_count);
b2Assert(0 <= index && index < m_count - 1);
edge->m_type = b2Shape::e_edge;
edge->m_radius = m_radius;
edge->m_hasVertex0 = true;
edge->m_hasVertex3 = true;
int32 i0 = index - 1 >= 0 ? index - 1 : m_count - 1;
int32 i1 = index;
int32 i2 = index + 1 < m_count ? index + 1 : 0;
int32 i3 = index + 2;
while (i3 >= m_count)
edge->m_vertex1 = m_vertices[index + 0];
edge->m_vertex2 = m_vertices[index + 1];
if (index > 0)
{
edge->m_vertex0 = m_vertices[index - 1];
edge->m_hasVertex0 = true;
}
else
{
i3 -= m_count;
edge->m_vertex0 = m_prevVertex;
edge->m_hasVertex0 = m_hasPrevVertex;
}
edge->m_vertex0 = m_vertices[i0];
edge->m_vertex1 = m_vertices[i1];
edge->m_vertex2 = m_vertices[i2];
edge->m_vertex3 = m_vertices[i3];
if (index < m_count - 2)
{
edge->m_vertex3 = m_vertices[index + 2];
edge->m_hasVertex3 = true;
}
else
{
edge->m_vertex3 = m_nextVertex;
edge->m_hasVertex3 = m_hasNextVertex;
}
}
bool b2LoopShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
bool b2ChainShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
{
B2_NOT_USED(xf);
B2_NOT_USED(p);
return false;
}
bool b2LoopShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
bool b2ChainShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
const b2Transform& xf, int32 childIndex) const
{
b2Assert(childIndex < m_count);
......@@ -102,7 +165,7 @@ bool b2LoopShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
return edgeShape.RayCast(output, input, xf, 0);
}
void b2LoopShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const
void b2ChainShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const
{
b2Assert(childIndex < m_count);
......@@ -120,7 +183,7 @@ void b2LoopShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIn
aabb->upperBound = b2Max(v1, v2);
}
void b2LoopShape::ComputeMass(b2MassData* massData, qreal density) const
void b2ChainShape::ComputeMass(b2MassData* massData, float32 density) const
{
B2_NOT_USED(density);
......
/*
* Copyright (c) 2006-2010 Erin Catto http://www.gphysics.com
* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
......@@ -16,28 +16,47 @@
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B2_LOOP_SHAPE_H
#define B2_LOOP_SHAPE_H
#ifndef B2_CHAIN_SHAPE_H
#define B2_CHAIN_SHAPE_H
#include <Box2D/Collision/Shapes/b2Shape.h>
class b2EdgeShape;
/// A loop shape is a free form sequence of line segments that form a circular list.
/// The loop may cross upon itself, but this is not recommended for smooth collision.
/// The loop has double sided collision, so you can use inside and outside collision.
/// A chain shape is a free form sequence of line segments.
/// The chain has two-sided collision, so you can use inside and outside collision.
/// Therefore, you may use any winding order.
/// Since there may be many vertices, they are allocated using b2Alloc.
class b2LoopShape : public b2Shape
/// Connectivity information is used to create smooth collisions.
/// WARNING: The chain will not collide properly if there are self-intersections.
class b2ChainShape : public b2Shape
{
public:
b2LoopShape();
b2ChainShape();
/// The destructor frees the vertices using b2Free.
~b2LoopShape();
~b2ChainShape();
/// Create the loop shape, copy all vertices.
void Create(const b2Vec2* vertices, int32 count);
/// Clear all data.
void Clear();
/// Create a loop. This automatically adjusts connectivity.
/// @param vertices an array of vertices, these are copied
/// @param count the vertex count
void CreateLoop(const b2Vec2* vertices, int32 count);
/// Create a chain with isolated end vertices.
/// @param vertices an array of vertices, these are copied
/// @param count the vertex count
void CreateChain(const b2Vec2* vertices, int32 count);
/// Establish connectivity to a vertex that precedes the first vertex.
/// Don't call this for loops.
void SetPrevVertex(const b2Vec2& prevVertex);
/// Establish connectivity to a vertex that follows the last vertex.
/// Don't call this for loops.
void SetNextVertex(const b2Vec2& nextVertex);
/// Implement b2Shape. Vertices are cloned using b2Alloc.
b2Shape* Clone(b2BlockAllocator* allocator) const;
......@@ -61,36 +80,26 @@ public:
/// Chains have zero mass.
/// @see b2Shape::ComputeMass
void ComputeMass(b2MassData* massData, qreal density) const;
/// Get the number of vertices.
int32 GetCount() const { return m_count; }
/// Get the vertices (read-only).
const b2Vec2& GetVertex(int32 index) const
{
b2Assert(0 <= index && index < m_count);
return m_vertices[index];
}
/// Get the vertices (read-only).
const b2Vec2* GetVertices() const { return m_vertices; }
protected:
void ComputeMass(b2MassData* massData, float32 density) const;
/// The vertices. Owned by this class.
b2Vec2* m_vertices;
/// The vertex count.
int32 m_count;
b2Vec2 m_prevVertex, m_nextVertex;
bool m_hasPrevVertex, m_hasNextVertex;
};
inline b2LoopShape::b2LoopShape()
inline b2ChainShape::b2ChainShape()
{
m_type = e_loop;
m_type = e_chain;
m_radius = b2_polygonRadius;
m_vertices = NULL;
m_count = 0;
m_hasPrevVertex = false;
m_hasNextVertex = false;
}
#endif
/*
* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
......@@ -18,7 +18,6 @@
#include <Box2D/Collision/Shapes/b2CircleShape.h>
#include <new>
using namespace std;
b2Shape* b2CircleShape::Clone(b2BlockAllocator* allocator) const
{
......@@ -35,7 +34,7 @@ int32 b2CircleShape::GetChildCount() const
bool b2CircleShape::TestPoint(const b2Transform& transform, const b2Vec2& p) const
{
b2Vec2 center = transform.position + b2Mul(transform.R, m_p);
b2Vec2 center = transform.p + b2Mul(transform.q, m_p);
b2Vec2 d = p - center;
return b2Dot(d, d) <= m_radius * m_radius;
}
......@@ -49,15 +48,15 @@ bool b2CircleShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input
{
B2_NOT_USED(childIndex);
b2Vec2 position = transform.position + b2Mul(transform.R, m_p);
b2Vec2 position = transform.