00001 /* 00002 * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com 00003 * 00004 * This software is provided 'as-is', without any express or implied 00005 * warranty. In no event will the authors be held liable for any damages 00006 * arising from the use of this software. 00007 * Permission is granted to anyone to use this software for any purpose, 00008 * including commercial applications, and to alter it and redistribute it 00009 * freely, subject to the following restrictions: 00010 * 1. The origin of this software must not be misrepresented; you must not 00011 * claim that you wrote the original software. If you use this software 00012 * in a product, an acknowledgment in the product documentation would be 00013 * appreciated but is not required. 00014 * 2. Altered source versions must be plainly marked as such, and must not be 00015 * misrepresented as being the original software. 00016 * 3. This notice may not be removed or altered from any source distribution. 00017 */ 00018 00019 #ifndef B2_SHAPE_H 00020 #define B2_SHAPE_H 00021 00022 #include <Box2D/Common/b2BlockAllocator.h> 00023 #include <Box2D/Common/b2Math.h> 00024 #include <Box2D/Collision/b2Collision.h> 00025 00027 struct b2MassData 00028 { 00030 float32 mass; 00031 00033 b2Vec2 center; 00034 00036 float32 I; 00037 }; 00038 00042 class b2Shape 00043 { 00044 public: 00045 00046 enum Type 00047 { 00048 e_unknown= -1, 00049 e_circle = 0, 00050 e_polygon = 1, 00051 e_typeCount = 2, 00052 }; 00053 00054 b2Shape() { m_type = e_unknown; } 00055 virtual ~b2Shape() {} 00056 00058 virtual b2Shape* Clone(b2BlockAllocator* allocator) const = 0; 00059 00062 Type GetType() const; 00063 00067 virtual bool TestPoint(const b2Transform& xf, const b2Vec2& p) const = 0; 00068 00073 virtual bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, const b2Transform& transform) const = 0; 00074 00078 virtual void ComputeAABB(b2AABB* aabb, const b2Transform& xf) const = 0; 00079 00084 virtual void ComputeMass(b2MassData* massData, float32 density) const = 0; 00085 00086 Type m_type; 00087 float32 m_radius; 00088 }; 00089 00090 inline b2Shape::Type b2Shape::GetType() const 00091 { 00092 return m_type; 00093 } 00094 00095 #endif