Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Sep 28, 2011 9:10 am 
Offline

Joined: Wed Sep 28, 2011 8:48 am
Posts: 1
I have a body of which I want to change the size and position. The idea is that its height shrinks, but it shifts down so that it is still resting on the static object below, without having to fall down. I know that it's desirable to never manually set the position for a body that is otherwise handled by the physics engine, but as far as I know, there is no other way.

When I do so while the body has no velocity (i.e., it is currently resting), it pops up, as if reacting to a collision between the body's NEW position / OLD size and the static object upon which it is resting. From what I can tell, this consistently happens three frames later.

When I do so while the body HAS velocity (i.e., it is moving horizontally), more often than not it doesn't pop up.

There is a layer of abstraction between my code and Bullet, and there's some other hoojiggery specific to the project, but the functions seen accessed here do exactly what they say and only what they say. The body's size and position are changed. Nothing else.

Code:
//gets the current position of the body
Vector4 newPos = getOwner()->getBody()->getPosition();

//scales the height of the velocity by 0.5, leaving the width and length as they were
getOwner()->getBody()->getShape()->scale(Vector4(1.0f,0.5f,1.0f,1.0f));

//calculates the new position where the body is shifted down so that it is still resting on the body below
newPos.setY(newPos.getY()-getOwner()->getBody()->getShape()->getSize().getY()+0.001f);

//sets the new position
getOwner()->getBody()->setPosition(newPos);


I am not an expert on Bullet, by any means. My team member set all of this up. I only use it when I need to. Unfortunately, he isn't sure what the problem is, either. I feel like there is something simple I am missing. Does Bullet not take the new size into account until after it next tests for collisions? So, in other words, the body is shifted down immediately, but the scaling is delayed?

Any help would be appreciated!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group