Skip to content

Commit

Permalink
v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
schteppe committed Jul 12, 2015
1 parent ebe6504 commit 3656f3f
Show file tree
Hide file tree
Showing 117 changed files with 15,383 additions and 6,730 deletions.
3,721 changes: 2,284 additions & 1,437 deletions build/p2.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions build/p2.min.js

Large diffs are not rendered by default.

45 changes: 26 additions & 19 deletions build/p2.renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16121,7 +16121,7 @@ function Renderer(scenes, options){
this.nullBody = new p2.Body();
this.pickPrecision = 5;

this.useInterpolatedPositions = false;
this.useInterpolatedPositions = true;

this.drawPoints = [];
this.drawPointsChangeEvent = { type : "drawPointsChange" };
Expand Down Expand Up @@ -16265,6 +16265,7 @@ Object.defineProperty(Renderer.prototype, 'paused', {
return this.settings['paused [p]'];
},
set: function(value) {
this.resetCallTime = true;
this.settings['paused [p]'] = value;
this.updateGUI();
}
Expand Down Expand Up @@ -16320,7 +16321,7 @@ Renderer.prototype.setupGUI = function() {
that.paused = p;
});
worldFolder.add(settings, 'manualStep [s]');
worldFolder.add(settings, 'fps', 60, 60*10).step(60).onChange(function(freq){
worldFolder.add(settings, 'fps', 10, 60*10).step(10).onChange(function(freq){
that.timeStep = 1 / freq;
});
worldFolder.add(settings, 'maxSubSteps', 0, 10).step(1);
Expand Down Expand Up @@ -16586,7 +16587,11 @@ Renderer.prototype.startRenderingLoop = function(){
function update(){
if(!demo.paused){
var now = Date.now() / 1000,
timeSinceLastCall = now-lastCallTime;
timeSinceLastCall = now - lastCallTime;
if(demo.resetCallTime){
timeSinceLastCall = 0;
demo.resetCallTime = false;
}
lastCallTime = now;
demo.world.step(demo.timeStep, timeSinceLastCall, demo.settings.maxSubSteps);
}
Expand Down Expand Up @@ -16764,7 +16769,7 @@ Renderer.prototype.handleMouseUp = function(physicsPosition){
if(R > 0){
// Create circle
b = new p2.Body({ mass : 1, position : this.drawCircleCenter });
var circle = new p2.Circle(R);
var circle = new p2.Circle({ radius: R });
b.addShape(circle);
this.world.addBody(b);
}
Expand Down Expand Up @@ -16793,7 +16798,7 @@ Renderer.prototype.handleMouseUp = function(physicsPosition){
mass : 1,
position : [this.drawRectStart[0] + width*0.5, this.drawRectStart[1] + height*0.5]
});
var rectangleShape = new p2.Rectangle(width, height);
var rectangleShape = new p2.Box({ width: width, height: height });
b.addShape(rectangleShape);
this.world.addBody(b);
}
Expand Down Expand Up @@ -16934,10 +16939,8 @@ Renderer.zoomOutEvent = {
};

Renderer.prototype.setEquationParameters = function(){
this.world.setGlobalEquationParameters({
stiffness: this.settings.stiffness,
relaxation: this.settings.relaxation
});
this.world.setGlobalStiffness(this.settings.stiffness);
this.world.setGlobalRelaxation(this.settings.relaxation);
};

})(p2);
Expand Down Expand Up @@ -17281,6 +17284,8 @@ WebGLRenderer.prototype.zoom = function(x, y, zoomOut, actualScaleX, actualScale
WebGLRenderer.prototype.centerCamera = function(x, y){
this.stage.position.x = this.renderer.width / 2 - this.stage.scale.x * x;
this.stage.position.y = this.renderer.height / 2 - this.stage.scale.y * y;

this.stage.updateTransform();
};

/**
Expand Down Expand Up @@ -17531,7 +17536,7 @@ WebGLRenderer.prototype.drawPath = function(g,path,color,fillColor,lineWidth,isS
};

WebGLRenderer.prototype.updateSpriteTransform = function(sprite,body){
if(this.useInterpolatedPositions){
if(this.useInterpolatedPositions && !this.paused){
sprite.position.x = body.interpolatedPosition[0];
sprite.position.y = body.interpolatedPosition[1];
sprite.rotation = body.interpolatedAngle;
Expand Down Expand Up @@ -17575,7 +17580,7 @@ WebGLRenderer.prototype.render = function(){
bA = s.bodyA,
bB = s.bodyB;

if(this.useInterpolatedPositions){
if(this.useInterpolatedPositions && !this.paused){
p2.vec2.toGlobalFrame(worldAnchorA, s.localAnchorA, bA.interpolatedPosition, bA.interpolatedAngle);
p2.vec2.toGlobalFrame(worldAnchorB, s.localAnchorB, bB.interpolatedPosition, bB.interpolatedAngle);
} else {
Expand Down Expand Up @@ -17661,6 +17666,10 @@ WebGLRenderer.prototype.render = function(){
this.aabbGraphics.cleared = true;
}

if(this.followBody){
app.centerCamera(this.followBody.interpolatedPosition[0], this.followBody.interpolatedPosition[1]);
}

this.renderer.render(this.container);
};

Expand Down Expand Up @@ -17710,10 +17719,8 @@ WebGLRenderer.prototype.drawRenderable = function(obj, graphics, color, lineColo
} else {
for(var i=0; i<obj.shapes.length; i++){
var child = obj.shapes[i],
offset = obj.shapeOffsets[i],
angle = obj.shapeAngles[i];
offset = offset || zero;
angle = angle || 0;
offset = child.position,
angle = child.angle;

if(child instanceof p2.Circle){
this.drawCircle(graphics, offset[0], offset[1], angle, child.radius,color,lw,isSleeping);
Expand All @@ -17728,7 +17735,7 @@ WebGLRenderer.prototype.drawRenderable = function(obj, graphics, color, lineColo
} else if(child instanceof p2.Line){
WebGLRenderer.drawLine(graphics, offset, angle, child.length, lineColor, lw);

} else if(child instanceof p2.Rectangle){
} else if(child instanceof p2.Box){
this.drawRectangle(graphics, offset[0], offset[1], angle, child.width, child.height, lineColor, color, lw, isSleeping);

} else if(child instanceof p2.Capsule){
Expand All @@ -17747,11 +17754,11 @@ WebGLRenderer.prototype.drawRenderable = function(obj, graphics, color, lineColo

} else if(child instanceof p2.Heightfield){
var path = [[0,-100]];
for(var j=0; j!==child.data.length; j++){
var v = child.data[j];
for(var j=0; j!==child.heights.length; j++){
var v = child.heights[j];
path.push([j*child.elementWidth, v]);
}
path.push([child.data.length*child.elementWidth,-100]);
path.push([child.heights.length*child.elementWidth,-100]);
this.drawPath(graphics, path, lineColor, color, lw, isSleeping);

}
Expand Down
14 changes: 7 additions & 7 deletions build/p2.renderer.min.js

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions docs/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ YUI.add("yuidoc-meta", function(Y) {
"AABB",
"AngleLockEquation",
"Body",
"Box",
"Broadphase",
"Capsule",
"Circle",
Expand All @@ -17,7 +18,6 @@ YUI.add("yuidoc-meta", function(Y) {
"FrictionEquation",
"GSSolver",
"GearConstraint",
"GridBroadphase",
"Heightfield",
"Island",
"IslandManager",
Expand All @@ -28,14 +28,14 @@ YUI.add("yuidoc-meta", function(Y) {
"Material",
"NaiveBroadphase",
"Narrowphase",
"Object pooling utility.",
"OverlapKeeper",
"OverlapKeeperRecord",
"Particle",
"Plane",
"PrismaticConstraint",
"Ray",
"RaycastResult",
"Rectangle",
"RevoluteConstraint",
"RotationalLockEquation",
"RotationalSpring",
Expand All @@ -44,10 +44,13 @@ YUI.add("yuidoc-meta", function(Y) {
"Shape",
"Solver",
"Spring",
"TopDownVehicle",
"TupleDictionary",
"Utils",
"WheelConstraint",
"World",
"vec2"
"vec2",
null
],
"modules": [],
"allModules": []
Expand Down
Loading

0 comments on commit 3656f3f

Please sign in to comment.