Something went wrong. Try again.
Box2d lite but uses fixed points instead of floats for embedded devices, fork from https://github.com/erincatto/box2d-lite github.com/erincatto/box2d-lite
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657/** Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com** Permission to use, copy, modify, distribute and sell this software* and its documentation for any purpose is hereby granted without fee,* provided that the above copyright notice appear in all copies.* Erin Catto makes no representations about the suitability * of this software for any purpose. * It is provided "as is" without express or implied warranty.*/
#include "box2d-lite/Body.h"
Body::Body(){ position.Set(0.0f, 0.0f); rotation = 0.0f; velocity.Set(0.0f, 0.0f); angularVelocity = 0.0f; force.Set(0.0f, 0.0f); torque = 0.0f; friction = 0.2f;
width.Set(1.0f, 1.0f); mass = FLT_MAX; invMass = 0.0f; I = FLT_MAX; invI = 0.0f;}
void Body::Set(const Vec2& w, float m){ position.Set(0.0f, 0.0f); rotation = 0.0f; velocity.Set(0.0f, 0.0f); angularVelocity = 0.0f; force.Set(0.0f, 0.0f); torque = 0.0f; friction = 0.2f;
width = w; mass = m;
if (mass < FLT_MAX) { invMass = 1.0f / mass; I = mass * (width.x * width.x + width.y * width.y) / 12.0f; invI = 1.0f / I; } else { invMass = 0.0f; I = FLT_MAX; invI = 0.0f; }}