behdad / box2d

Automatically exported from code.google.com/p/box2d
2 stars 12 forks source link

b2Polygone::Set() usage leads to incorrect joint definition/usage #191

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Create shape A with b2Polygone::Set() method, giving n number of vertices 
(where n = 3). Attach it to body A with definition defined without any position
2. Repeat Step 1 to create another body object. Don't overlap shape object 
vertices
3. Create a revolute joint between the two bodies (pivot it somewhere between).

What is the expected output? What do you see instead?
Expected: Two bodies are created at vertices given and a joint is created.
Observed: Two bodies are created at vertices given, but the joint is created 
from 0,0 to pivot point. The bodies do revolve around the joint, but the 
reported angle on the joint is wrong.

If I set the position of the body definition when creating bodies, then the 
joints are fine, but the body is not being put at the vertices given. This is 
because the position of the body is being computed with given vertices + a 
transform (position). 

What version of the product are you using? On what operating system?
I am using Box2D 2.1.2 on Mac OS under Xcode 4.0

Please provide any additional information below.
It seems like the position transform on the body object should be computed 
using the vertices. A centeriod is already being computed. Perhaps that can be 
used?

I am attaching a test file that creates two bodies with said problem.

Original issue reported on code.google.com by psa...@gmail.com on 18 Apr 2011 at 2:13

Attachments:

GoogleCodeExporter commented 9 years ago
I think you misunderstand the joint debug draw. It draws lines from the anchor 
points to the body origin, not the body center of mass.

Original comment by erinca...@gmail.com on 26 Jun 2011 at 10:17