Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Alexandre.Meyer/m1if37-animation
  • Alexandre.Meyer/m2-apprentissage-profond-image
  • Alexandre.Meyer/m2-animation
  • Alexandre.Meyer/hugo-web-minimal
  • Alexandre.Meyer/lifami
  • Alexandre.Meyer/lifapcd
  • Alexandre.Meyer/www
  • Alexandre.Meyer/lifstage
8 results
Show changes
Showing
with 0 additions and 782 deletions
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Box2D" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="../lib/win32/Box2D_d" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Debug/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="../lib/win32/Box2D" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Release/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-std=c++11" />
<Add directory="../src" />
</Compiler>
<Unit filename="../src/Box2D/Box2D.h" />
<Unit filename="../src/Box2D/Collision/Shapes/b2ChainShape.cpp" />
<Unit filename="../src/Box2D/Collision/Shapes/b2ChainShape.h" />
<Unit filename="../src/Box2D/Collision/Shapes/b2CircleShape.cpp" />
<Unit filename="../src/Box2D/Collision/Shapes/b2CircleShape.h" />
<Unit filename="../src/Box2D/Collision/Shapes/b2EdgeShape.cpp" />
<Unit filename="../src/Box2D/Collision/Shapes/b2EdgeShape.h" />
<Unit filename="../src/Box2D/Collision/Shapes/b2PolygonShape.cpp" />
<Unit filename="../src/Box2D/Collision/Shapes/b2PolygonShape.h" />
<Unit filename="../src/Box2D/Collision/Shapes/b2Shape.h" />
<Unit filename="../src/Box2D/Collision/b2BroadPhase.cpp" />
<Unit filename="../src/Box2D/Collision/b2BroadPhase.h" />
<Unit filename="../src/Box2D/Collision/b2CollideCircle.cpp" />
<Unit filename="../src/Box2D/Collision/b2CollideEdge.cpp" />
<Unit filename="../src/Box2D/Collision/b2CollidePolygon.cpp" />
<Unit filename="../src/Box2D/Collision/b2Collision.cpp" />
<Unit filename="../src/Box2D/Collision/b2Collision.h" />
<Unit filename="../src/Box2D/Collision/b2Distance.cpp" />
<Unit filename="../src/Box2D/Collision/b2Distance.h" />
<Unit filename="../src/Box2D/Collision/b2DynamicTree.cpp" />
<Unit filename="../src/Box2D/Collision/b2DynamicTree.h" />
<Unit filename="../src/Box2D/Collision/b2TimeOfImpact.cpp" />
<Unit filename="../src/Box2D/Collision/b2TimeOfImpact.h" />
<Unit filename="../src/Box2D/Common/b2BlockAllocator.cpp" />
<Unit filename="../src/Box2D/Common/b2BlockAllocator.h" />
<Unit filename="../src/Box2D/Common/b2Draw.cpp" />
<Unit filename="../src/Box2D/Common/b2Draw.h" />
<Unit filename="../src/Box2D/Common/b2GrowableStack.h" />
<Unit filename="../src/Box2D/Common/b2Math.cpp" />
<Unit filename="../src/Box2D/Common/b2Math.h" />
<Unit filename="../src/Box2D/Common/b2Settings.cpp" />
<Unit filename="../src/Box2D/Common/b2Settings.h" />
<Unit filename="../src/Box2D/Common/b2StackAllocator.cpp" />
<Unit filename="../src/Box2D/Common/b2StackAllocator.h" />
<Unit filename="../src/Box2D/Common/b2Timer.cpp" />
<Unit filename="../src/Box2D/Common/b2Timer.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2CircleContact.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2CircleContact.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2Contact.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2Contact.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2ContactSolver.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2ContactSolver.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2PolygonContact.cpp" />
<Unit filename="../src/Box2D/Dynamics/Contacts/b2PolygonContact.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2DistanceJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2DistanceJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2FrictionJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2FrictionJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2GearJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2GearJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2Joint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2Joint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2MotorJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2MotorJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2MouseJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2MouseJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2PrismaticJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2PulleyJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2PulleyJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2RevoluteJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2RopeJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2RopeJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2WeldJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2WeldJoint.h" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2WheelJoint.cpp" />
<Unit filename="../src/Box2D/Dynamics/Joints/b2WheelJoint.h" />
<Unit filename="../src/Box2D/Dynamics/b2Body.cpp" />
<Unit filename="../src/Box2D/Dynamics/b2Body.h" />
<Unit filename="../src/Box2D/Dynamics/b2ContactManager.cpp" />
<Unit filename="../src/Box2D/Dynamics/b2ContactManager.h" />
<Unit filename="../src/Box2D/Dynamics/b2Fixture.cpp" />
<Unit filename="../src/Box2D/Dynamics/b2Fixture.h" />
<Unit filename="../src/Box2D/Dynamics/b2Island.cpp" />
<Unit filename="../src/Box2D/Dynamics/b2Island.h" />
<Unit filename="../src/Box2D/Dynamics/b2TimeStep.h" />
<Unit filename="../src/Box2D/Dynamics/b2World.cpp" />
<Unit filename="../src/Box2D/Dynamics/b2World.h" />
<Unit filename="../src/Box2D/Dynamics/b2WorldCallbacks.cpp" />
<Unit filename="../src/Box2D/Dynamics/b2WorldCallbacks.h" />
<Unit filename="../src/Box2D/Rope/b2Rope.cpp" />
<Unit filename="../src/Box2D/Rope/b2Rope.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="GLEW" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="../lib/win32/GLEW_d" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Debug/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="../lib/win32/GLEW" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Release/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-std=c++11" />
<Add option="-Wattributes" />
<Add directory="../src" />
</Compiler>
<Unit filename="../src/glew/glew.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glew/glew.h" />
<Unit filename="../src/glew/glxew.h" />
<Unit filename="../src/glew/wglew.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="GLFW" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="../lib/win32/GLFW_d" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Debug/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="../lib/win32/GLFW" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Release/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add directory="../src" />
</Compiler>
<Unit filename="../src/glfw/context.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/egl_context.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/egl_context.h" />
<Unit filename="../src/glfw/glfw3.h" />
<Unit filename="../src/glfw/glfw3native.h" />
<Unit filename="../src/glfw/glfw_config.h" />
<Unit filename="../src/glfw/init.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/input.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/internal.h" />
<Unit filename="../src/glfw/monitor.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/vulkan.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/wgl_context.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/wgl_context.h" />
<Unit filename="../src/glfw/win32_init.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/win32_joystick.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/win32_joystick.h" />
<Unit filename="../src/glfw/win32_monitor.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/win32_platform.h" />
<Unit filename="../src/glfw/win32_time.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/win32_tls.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/win32_window.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/glfw/window.c">
<Option compilerVar="CC" />
</Unit>
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="IMGUI" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="../lib/linux/IMGUI_d" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Debug/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="../lib/linux/IMGUI" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Release/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-std=c++11" />
<Add option="-DGLEW_STATIC" />
<Add directory="../src" />
</Compiler>
<Unit filename="../src/imgui/imconfig.h" />
<Unit filename="../src/imgui/imgui.cpp" />
<Unit filename="../src/imgui/imgui.h" />
<Unit filename="../src/imgui/imgui_demo.cpp" />
<Unit filename="../src/imgui/imgui_draw.cpp" />
<Unit filename="../src/imgui/imgui_impl_glfw_gl3.cpp" />
<Unit filename="../src/imgui/imgui_impl_glfw_gl3.h" />
<Unit filename="../src/imgui/imgui_internal.h" />
<Unit filename="../src/imgui/stb_rect_pack.h" />
<Unit filename="../src/imgui/stb_textedit.h" />
<Unit filename="../src/imgui/stb_truetype.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="IMGUI" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="../lib/win32/IMGUI_d" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Debug/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="../lib/win32/IMGUI" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Release/" />
<Option type="2" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-std=c++11" />
<Add option="-DGLEW_STATIC" />
<Add directory="../src" />
</Compiler>
<Unit filename="../src/imgui/imconfig.h" />
<Unit filename="../src/imgui/imgui.cpp" />
<Unit filename="../src/imgui/imgui.h" />
<Unit filename="../src/imgui/imgui_demo.cpp" />
<Unit filename="../src/imgui/imgui_draw.cpp" />
<Unit filename="../src/imgui/imgui_impl_glfw_gl3.cpp" />
<Unit filename="../src/imgui/imgui_impl_glfw_gl3.h" />
<Unit filename="../src/imgui/imgui_internal.h" />
<Unit filename="../src/imgui/stb_rect_pack.h" />
<Unit filename="../src/imgui/stb_textedit.h" />
<Unit filename="../src/imgui/stb_truetype.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
/*
* 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
/*
* 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
* 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.
*/
#include "Box2D/Collision/Shapes/b2ChainShape.h"
#include "Box2D/Collision/Shapes/b2EdgeShape.h"
#include <new>
#include <string.h>
b2ChainShape::~b2ChainShape()
{
Clear();
}
void b2ChainShape::Clear()
{
b2Free(m_vertices);
m_vertices = nullptr;
m_count = 0;
}
void b2ChainShape::CreateLoop(const b2Vec2* vertices, int32 count)
{
b2Assert(m_vertices == nullptr && m_count == 0);
b2Assert(count >= 3);
if (count < 3)
{
return;
}
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 == nullptr && 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();
}
void b2ChainShape::SetPrevVertex(const b2Vec2& prevVertex)
{
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 b2ChainShape::GetChildCount() const
{
// edge count = vertex count - 1
return m_count - 1;
}
void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
{
b2Assert(0 <= index && index < m_count - 1);
edge->m_type = b2Shape::e_edge;
edge->m_radius = m_radius;
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
{
edge->m_vertex0 = m_prevVertex;
edge->m_hasVertex0 = m_hasPrevVertex;
}
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 b2ChainShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
{
B2_NOT_USED(xf);
B2_NOT_USED(p);
return false;
}
bool b2ChainShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
const b2Transform& xf, int32 childIndex) const
{
b2Assert(childIndex < m_count);
b2EdgeShape edgeShape;
int32 i1 = childIndex;
int32 i2 = childIndex + 1;
if (i2 == m_count)
{
i2 = 0;
}
edgeShape.m_vertex1 = m_vertices[i1];
edgeShape.m_vertex2 = m_vertices[i2];
return edgeShape.RayCast(output, input, xf, 0);
}
void b2ChainShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const
{
b2Assert(childIndex < m_count);
int32 i1 = childIndex;
int32 i2 = childIndex + 1;
if (i2 == m_count)
{
i2 = 0;
}
b2Vec2 v1 = b2Mul(xf, m_vertices[i1]);
b2Vec2 v2 = b2Mul(xf, m_vertices[i2]);
aabb->lowerBound = b2Min(v1, v2);
aabb->upperBound = b2Max(v1, v2);
}
void b2ChainShape::ComputeMass(b2MassData* massData, float32 density) const
{
B2_NOT_USED(density);
massData->mass = 0.0f;
massData->center.SetZero();
massData->I = 0.0f;
}
/*
* 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
* 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 B2_CHAIN_SHAPE_H
#define B2_CHAIN_SHAPE_H
#include "Box2D/Collision/Shapes/b2Shape.h"
class b2EdgeShape;
/// 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.
/// 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:
b2ChainShape();
/// The destructor frees the vertices using b2Free.
~b2ChainShape();
/// 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 override;
/// @see b2Shape::GetChildCount
int32 GetChildCount() const override;
/// Get a child edge.
void GetChildEdge(b2EdgeShape* edge, int32 index) const;
/// This always return false.
/// @see b2Shape::TestPoint
bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override;
/// Implement b2Shape.
bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
const b2Transform& transform, int32 childIndex) const override;
/// @see b2Shape::ComputeAABB
void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override;
/// Chains have zero mass.
/// @see b2Shape::ComputeMass
void ComputeMass(b2MassData* massData, float32 density) const override;
/// 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 b2ChainShape::b2ChainShape()
{
m_type = e_chain;
m_radius = b2_polygonRadius;
m_vertices = nullptr;
m_count = 0;
m_hasPrevVertex = false;
m_hasNextVertex = false;
}
#endif