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.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859/** 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"
#include <float.h>
Body::Body(){ position.Set(fixed_float(0.0f), fixed_float(0.0f)); rotation = fixed_float(0.0f); velocity.Set(fixed_float(0.0f), fixed_float(0.0f)); angularVelocity = fixed_float(0.0f); force.Set(fixed_float(0.0f), fixed_float(0.0f)); torque = fixed_float(0.0f); friction = fixed_float(0.2f);
width.Set(fixed_float(1.0f), fixed_float(1.0f)); mass = fixed_float(FLT_MAX); invMass = fixed_float(0.0f); I = fixed_float(FLT_MAX); invI = fixed_float(0.0f);}
void Body::Set(const Vec2& w, fixed_float m){ position.Set(fixed_float(0.0f), fixed_float(0.0f)); rotation = fixed_float(0.0f); velocity.Set(fixed_float(0.0f), fixed_float(0.0f)); angularVelocity = fixed_float(0.0f); force.Set(fixed_float(0.0f), fixed_float(0.0f)); torque = fixed_float(0.0f); friction = fixed_float(0.2f);
width = w; mass = m;
if (mass < fixed_float(FLT_MAX)) { invMass = fixed_float(1.0f) / mass; I = mass * (width.x * width.x + width.y * width.y) / fixed_float(12.0f); invI = fixed_float(1.0f) / I; } else { invMass = fixed_float(0.0f); I = fixed_float(FLT_MAX); invI = fixed_float(0.0f); }}