Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Vanderlin committed Nov 16, 2013
1 parent 170ea0e commit 5f327d8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
4 changes: 4 additions & 0 deletions example-Bodies/example-Bodies.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@
/* Begin PBXProject section */
E4B69B4C0A3A1720003C02F2 /* Project object */ = {
isa = PBXProject;
attributes = {
};
buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "example-Bodies" */;
compatibilityVersion = "Xcode 2.4";
developmentRegion = English;
Expand Down Expand Up @@ -685,6 +687,7 @@
"-lpthread",
"-mtune=native",
);
SDKROOT = macosx10.8;
};
name = Debug;
};
Expand Down Expand Up @@ -728,6 +731,7 @@
"-lpthread",
"-mtune=native",
);
SDKROOT = macosx10.8;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
Expand All @@ -39,11 +39,12 @@
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
Expand Down
24 changes: 12 additions & 12 deletions src/ofxBox2dPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,38 +199,38 @@ void ofxBox2dPolygon::create(b2World * b2dworld) {

}
else {
vector<ofPoint> pts = ofPolyline::getVertices();
if(bSetAsEdge) {
for (int i=1; i<size(); i++) {
for (int i=1; i<pts.size(); i++) {
b2PolygonShape shape;
b2Vec2 a = screenPtToWorldPt(getVertices()[i-1]);
b2Vec2 b = screenPtToWorldPt(getVertices()[i]);
b2Vec2 a = screenPtToWorldPt(pts[i-1]);
b2Vec2 b = screenPtToWorldPt(pts[i]);
shape.SetAsEdge(a, b);
fixture.shape = &shape;
fixture.density = density;
fixture.restitution = bounce;
fixture.friction = friction;
fixture.friction = friction;

body->CreateFixture(&fixture);
}
}
}
else {
vector<b2Vec2>verts;
verts.assign(size()-1, b2Vec2());
for (int i=0; i<size(); i++) {
ofVec2f p = getVertices()[i] / OFX_BOX2D_SCALE;
verts.assign(pts.size()-1, b2Vec2());
for (int i=0; i<pts.size(); i++) {
ofVec2f p = pts[i] / OFX_BOX2D_SCALE;
verts[i] = b2Vec2(p.x, p.y);
}
b2PolygonShape shape;
shape.Set(&verts[0], size()-1);
shape.Set(&verts[0], pts.size()-1);

fixture.shape = &shape;
fixture.density = density;
fixture.restitution = bounce;
fixture.friction = friction;
fixture.friction = friction;

body->CreateFixture(&fixture);
}

}
}

// update the area and centroid
Expand Down

0 comments on commit 5f327d8

Please sign in to comment.