c++ - Box2d cpp gives : box2d expression area > 1.1 exception -


i have strange error :

#define ptm_ratio 32 // shape             b2polygonshape axleshape;             axleshape.setasbox(20/ptm_ratio,20/ptm_ratio);              // fixture             b2fixturedef axlefixture;             axlefixture.density=0.5;             axlefixture.friction=3;             axlefixture.restitution=0.3;             axlefixture.shape=&axleshape;             axlefixture.filter.groupindex=-1;             // body definition             b2bodydef axlebodydef;             axlebodydef.type=b2_dynamicbody;             // rear axle             axlebodydef.position.set(m_cart->getworldcenter().x-(60/ptm_ratio),m_cart->getworldcenter().y+(65/ptm_ratio));             b2body* rearaxle =m_world->createbody(&axlebodydef);             rearaxle->createfixture(&axlefixture);             // front axle             axlebodydef.position.set(m_cart->getworldcenter().x+(75/ptm_ratio),m_cart->getworldcenter().y+(65/ptm_ratio));             b2body* frontaxle=m_world->createbody(&axlebodydef);             frontaxle->createfixture(&axlefixture); 

in last line im getting exception says : enter image description here

when change :

axleshape.setasbox(40/ptm_ratio,40/ptm_ratio); 

it working , not in right size need . how can make small box's?

this case of integer division. when pass 20/ptm_ratio setasbox method, same 20/32, evaluates 0.

you can fix changing first line #define ptm_ratio 32.0. point 0 @ end should make of division expressions evaluate decimal.

the assert "area > 1.192092896e-07" makes sure area of shape larger number. program won't compile if assert fails. @ moment, you're passing in half-width , half-height of 0, means area of rectangle 0, , causes assert fail.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -