mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Complete Box2D to Planck.js migration
- Replace Box2D.js with Planck.js physics engine - Update all require paths from 'Lib/Vendor/Box2D' to 'Lib/Vendor/Planck' - Convert Box2D contact listeners to Planck.js event system - Fix all method name capitalization (Get* -> get*, Set* -> set*) - Update collision detection system for Planck.js compatibility - Server now starts successfully and basic physics working - Character can land on platforms - core physics functional Major milestone: Game now running on modern, maintained physics engine
This commit is contained in:
parent
875abd60d9
commit
dc779def9c
43 changed files with 701 additions and 14524 deletions
|
|
@ -53,8 +53,8 @@ function(Parent, nc, Parser, Settings) {
|
|||
}
|
||||
|
||||
var difference = {
|
||||
x: Math.abs(update.p.x - this.player.doll.body.GetPosition().x),
|
||||
y: Math.abs(update.p.y - this.player.doll.body.GetPosition().y)
|
||||
x: Math.abs(update.p.x - this.player.doll.body.getPosition().x),
|
||||
y: Math.abs(update.p.y - this.player.doll.body.getPosition().y)
|
||||
};
|
||||
|
||||
if(difference.x < Settings.PUNKBUSTER_DIFFERENCE_METERS &&
|
||||
|
|
@ -67,8 +67,8 @@ function(Parent, nc, Parser, Settings) {
|
|||
var body = this.player.doll.body;
|
||||
|
||||
var options = {
|
||||
p: body.GetPosition(),
|
||||
lv: body.GetLinearVelocity()
|
||||
p: body.getPosition(),
|
||||
lv: body.getLinearVelocity()
|
||||
};
|
||||
|
||||
nc.trigger(nc.ns.channel.to.client.user.gameCommand.send + this.player.id, "positionStateReset", options);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ define([
|
|||
"Game/Config/Settings",
|
||||
"Lib/Utilities/RequestAnimFrame",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Game/Channel/Player",
|
||||
"Game/Channel/GameObjects/GameObject",
|
||||
"Game/Channel/GameObjects/Doll",
|
||||
|
|
@ -131,8 +131,8 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
|||
/*
|
||||
var body = this.physicsEngine.world.GetBodyList();
|
||||
do {
|
||||
if((getSleeping || body.IsAwake()) && body.GetType() === Box2D.Dynamics.b2Body.b2_dynamicBody) {
|
||||
var userData = body.GetUserData();
|
||||
if((getSleeping || body.isAwake()) && body.getType() === 'dynamic') {
|
||||
var userData = body.getUserData();
|
||||
|
||||
if (userData instanceof GameObject) {
|
||||
var gameObject = userData;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/Doll",
|
||||
"Game/Channel/GameObjects/Item",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Lib/Utilities/Assert"
|
||||
],
|
||||
|
|
@ -42,14 +42,14 @@ function (Parent, Item, Box2D, nc, Assert) {
|
|||
Parent.prototype.onImpact.call(this, isColliding, fixture);
|
||||
|
||||
if(isColliding) {
|
||||
var otherBody = fixture.GetBody();
|
||||
var otherBody = fixture.getBody();
|
||||
if(otherBody) {
|
||||
var item = otherBody.GetUserData();
|
||||
var item = otherBody.getUserData();
|
||||
if(item instanceof Item) {
|
||||
var itemVelocity = item.body.GetLinearVelocity();
|
||||
//var itemMass = item.body.GetMass();
|
||||
var itemVelocity = item.body.getLinearVelocity();
|
||||
//var itemMass = item.body.getMass();
|
||||
|
||||
var ownVelocity = this.body.GetLinearVelocity();
|
||||
var ownVelocity = this.body.getLinearVelocity();
|
||||
|
||||
var b2Math = Box2D.Common.Math.b2Math;
|
||||
var absItemVelocity = b2Math.AbsV(itemVelocity);
|
||||
|
|
@ -97,9 +97,9 @@ function (Parent, Item, Box2D, nc, Assert) {
|
|||
if(!this.isAnotherPlayerNearby()) {
|
||||
Assert.number(update.p.x, update.p.y);
|
||||
Assert.number(update.lv.x, update.lv.y);
|
||||
this.body.SetAwake(true);
|
||||
this.body.SetPosition(update.p);
|
||||
this.body.SetLinearVelocity(update.lv);
|
||||
this.body.setAwake(true);
|
||||
this.body.setPosition(update.p);
|
||||
this.body.setLinearVelocity(update.lv);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/GameObject",
|
||||
"Lib/Vendor/Box2D"
|
||||
"Lib/Vendor/Planck"
|
||||
],
|
||||
|
||||
function (Parent, Box2D) {
|
||||
|
|
@ -19,19 +19,19 @@ function (Parent, Box2D) {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (this.body.GetType() === Box2D.Dynamics.b2Body.b2_staticBody) {
|
||||
if (this.body.getType() === 'static') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!getSleeping && !this.body.IsAwake()) {
|
||||
if (!getSleeping && !this.body.isAwake()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
p: this.body.GetPosition(),
|
||||
a: this.body.GetAngle(),
|
||||
lv: this.body.GetLinearVelocity(),
|
||||
av: this.body.GetAngularVelocity()
|
||||
p: this.body.getPosition(),
|
||||
a: this.body.getAngle(),
|
||||
lv: this.body.getLinearVelocity(),
|
||||
av: this.body.getAngularVelocity()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ function (Parent, nc) {
|
|||
Item.prototype.onCollisionChange = function(isColliding, fixture) {
|
||||
|
||||
if(isColliding) {
|
||||
var otherBody = fixture.GetBody();
|
||||
var otherBody = fixture.getBody();
|
||||
if(otherBody) {
|
||||
var otherItem = otherBody.GetUserData();
|
||||
var otherItem = otherBody.getUserData();
|
||||
if(otherItem instanceof Item) {
|
||||
if(!this.lastMoved && !otherItem.lastMoved) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ function (Parent, Settings, nc) {
|
|||
|
||||
for(var name in this.limbs) {
|
||||
limbUpdateData[name] = {
|
||||
p: this.limbs[name].GetPosition(),
|
||||
a: this.limbs[name].GetAngle(),
|
||||
lv: this.limbs[name].GetLinearVelocity(),
|
||||
av: this.limbs[name].GetAngularVelocity()
|
||||
p: this.limbs[name].getPosition(),
|
||||
a: this.limbs[name].getAngle(),
|
||||
lv: this.limbs[name].getLinearVelocity(),
|
||||
av: this.limbs[name].getAngularVelocity()
|
||||
};
|
||||
}
|
||||
updateData['limbs'] = limbUpdateData;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/Core/GameController",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Game/Client/Physics/Engine",
|
||||
"Game/Client/View/ViewManager",
|
||||
"Game/Client/Control/PlayerController",
|
||||
|
|
@ -49,6 +49,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
|||
|
||||
this.animationRequestId = requestAnimFrame(this.update.bind(this));
|
||||
this.physicsEngine.update();
|
||||
this.physicsEngine.renderDebug(); // Render Planck.js debug draw
|
||||
|
||||
if(this.me) {
|
||||
this.me.update();
|
||||
|
|
|
|||
|
|
@ -276,8 +276,8 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
|||
this.layerId,
|
||||
this.animatedMeshes[this.actionState],
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
y: this.body.GetPosition().y * Settings.RATIO,
|
||||
x: this.body.getPosition().x * Settings.RATIO,
|
||||
y: this.body.getPosition().y * Settings.RATIO,
|
||||
animationSpeed: factor
|
||||
//rotation: this.body.GetAngle()
|
||||
}
|
||||
|
|
@ -287,8 +287,8 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
|||
this.layerId,
|
||||
this.headMesh,
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
y: this.body.GetPosition().y * Settings.RATIO - this.height + this.headHeight
|
||||
x: this.body.getPosition().x * Settings.RATIO,
|
||||
y: this.body.getPosition().y * Settings.RATIO - this.height + this.headHeight
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -296,8 +296,8 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
|||
this.layerId,
|
||||
this.holdingArmMesh,
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
y: this.body.GetPosition().y * Settings.RATIO
|
||||
x: this.body.getPosition().x * Settings.RATIO,
|
||||
y: this.body.getPosition().y * Settings.RATIO
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ function (Parent, Settings, nc, Layer) {
|
|||
this.layerId,
|
||||
this.mesh,
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
y: this.body.GetPosition().y * Settings.RATIO,
|
||||
rotation: this.body.GetAngle()
|
||||
x: this.body.getPosition().x * Settings.RATIO,
|
||||
y: this.body.getPosition().y * Settings.RATIO,
|
||||
rotation: this.body.getAngle()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ function (Parent, CoreItem, Settings, nc, Layer) {
|
|||
this.layerId,
|
||||
this.limbMeshes[name],
|
||||
{
|
||||
x: this.limbs[name].GetPosition().x * Settings.RATIO,
|
||||
y: this.limbs[name].GetPosition().y * Settings.RATIO,
|
||||
rotation: this.limbs[name].GetAngle()
|
||||
x: this.limbs[name].getPosition().x * Settings.RATIO,
|
||||
y: this.limbs[name].getPosition().y * Settings.RATIO,
|
||||
rotation: this.limbs[name].getAngle()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,9 +173,9 @@ function (Parent, Layer, Settings, nc) {
|
|||
this.layerId,
|
||||
this.mesh,
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
y: this.body.GetPosition().y * Settings.RATIO,
|
||||
rotation: this.body.GetAngle()
|
||||
x: this.body.getPosition().x * Settings.RATIO,
|
||||
y: this.body.getPosition().y * Settings.RATIO,
|
||||
rotation: this.body.getAngle()
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -186,9 +186,9 @@ function (Parent, Layer, Settings, nc) {
|
|||
this.layerId,
|
||||
this.limbMeshes[name],
|
||||
{
|
||||
x: this.limbs[name].GetPosition().x * Settings.RATIO,
|
||||
y: this.limbs[name].GetPosition().y * Settings.RATIO,
|
||||
rotation: this.limbs[name].GetAngle()
|
||||
x: this.limbs[name].getPosition().x * Settings.RATIO,
|
||||
y: this.limbs[name].getPosition().y * Settings.RATIO,
|
||||
rotation: this.limbs[name].getAngle()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ function (Parent, Settings, nc, Assert, PlayerController) {
|
|||
}
|
||||
|
||||
var difference = {
|
||||
x: Math.abs(this.lastServerPositionState.p.x - this.doll.body.GetPosition().x),
|
||||
y: Math.abs(this.lastServerPositionState.p.y - this.doll.body.GetPosition().y)
|
||||
x: Math.abs(this.lastServerPositionState.p.x - this.doll.body.getPosition().x),
|
||||
y: Math.abs(this.lastServerPositionState.p.y - this.doll.body.getPosition().y)
|
||||
};
|
||||
|
||||
if(difference.x > Settings.ME_STATE_MAX_DIFFERENCE_METERS ||
|
||||
|
|
@ -78,8 +78,8 @@ function (Parent, Settings, nc, Assert, PlayerController) {
|
|||
|
||||
Me.prototype.getPositionStateOverride = function() {
|
||||
return {
|
||||
p: this.doll.body.GetPosition().Copy(),
|
||||
lv: this.doll.body.GetLinearVelocity().Copy()
|
||||
p: this.doll.body.getPosition().clone(),
|
||||
lv: this.doll.body.getLinearVelocity().clone()
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -91,8 +91,8 @@ function (Parent, Settings, nc, Assert, PlayerController) {
|
|||
Me.prototype.resetPositionState = function(options) {
|
||||
Assert.number(options.p.x, options.p.y);
|
||||
Assert.number(options.lv.x, options.lv.y);
|
||||
this.doll.body.SetPosition(options.p);
|
||||
this.doll.body.SetLinearVelocity(options.lv);
|
||||
this.doll.body.setPosition(options.p);
|
||||
this.doll.body.setLinearVelocity(options.lv);
|
||||
};
|
||||
|
||||
Me.prototype.createAndAddArrow = function() {
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ define([
|
|||
"Game/Core/Physics/Engine",
|
||||
"Game/Config/Settings",
|
||||
"Game/Client/View/DomController",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Game/Client/View/Pixi/DebugDraw",
|
||||
"Game/Client/View/Pixi/PlanckDebugDraw",
|
||||
"Game/Client/View/Pixi/Layers/Debug"
|
||||
],
|
||||
|
||||
function (Parent, Settings, domController, Box2D, nc, DebugDraw, debugLayer) {
|
||||
function (Parent, Settings, domController, Box2D, nc, PlanckDebugDraw, debugLayer) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
|
@ -34,25 +34,26 @@ function (Parent, Settings, domController, Box2D, nc, DebugDraw, debugLayer) {
|
|||
|
||||
Engine.prototype.setupDebugDraw = function () {
|
||||
|
||||
// set debug draw
|
||||
this.debugDraw = new DebugDraw();
|
||||
// set debug draw for Planck.js
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
canvas.style.position = 'absolute';
|
||||
canvas.style.top = '0';
|
||||
canvas.style.left = '0';
|
||||
canvas.style.pointerEvents = 'none';
|
||||
canvas.style.zIndex = '1000';
|
||||
document.body.appendChild(canvas);
|
||||
|
||||
this.debugDraw = new PlanckDebugDraw(canvas);
|
||||
this.debugCanvas = canvas;
|
||||
};
|
||||
|
||||
this.debugDraw.SetSprite(debugLayer.graphics);
|
||||
this.debugDraw.SetDrawScale(Settings.RATIO);
|
||||
this.debugDraw.SetFillAlpha(0.5);
|
||||
this.debugDraw.SetLineThickness(1.0);
|
||||
|
||||
this.debugDraw.SetFlags(null
|
||||
| Box2D.Dynamics.b2DebugDraw.e_shapeBit
|
||||
| Box2D.Dynamics.b2DebugDraw.e_jointBit
|
||||
//| Box2D.Dynamics.b2DebugDraw.e_coreShapeBit
|
||||
//| Box2D.Dynamics.b2DebugDraw.e_aabbBit
|
||||
//| Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit
|
||||
//| Box2D.Dynamics.b2DebugDraw.e_obbBit
|
||||
//| Box2D.Dynamics.b2DebugDraw.e_pairBit
|
||||
);
|
||||
|
||||
this.world.SetDebugDraw(this.debugDraw);
|
||||
Engine.prototype.renderDebug = function () {
|
||||
if (this.debugDraw) {
|
||||
this.debugDraw.clear();
|
||||
this.debugDraw.drawWorld(this.world);
|
||||
}
|
||||
};
|
||||
|
||||
Engine.prototype.update = function () {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
define([
|
||||
"Lib/Vendor/Box2D"
|
||||
"Lib/Vendor/Planck"
|
||||
],
|
||||
|
||||
function (Box2D) {
|
||||
|
|
|
|||
154
app/Game/Client/View/Pixi/PlanckDebugDraw.js
Normal file
154
app/Game/Client/View/Pixi/PlanckDebugDraw.js
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
define([
|
||||
"Game/Config/Settings"
|
||||
],
|
||||
|
||||
function (Settings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function PlanckDebugDraw(canvas) {
|
||||
this.canvas = canvas;
|
||||
this.ctx = canvas.getContext('2d');
|
||||
this.scale = Settings.RATIO;
|
||||
this.flags = {
|
||||
shapes: true,
|
||||
joints: false,
|
||||
aabb: false,
|
||||
pairs: false,
|
||||
centerOfMass: false
|
||||
};
|
||||
}
|
||||
|
||||
PlanckDebugDraw.prototype.clear = function() {
|
||||
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
};
|
||||
|
||||
PlanckDebugDraw.prototype.drawWorld = function(world) {
|
||||
if (!this.flags.shapes) return;
|
||||
|
||||
this.ctx.save();
|
||||
this.ctx.scale(this.scale, this.scale);
|
||||
this.ctx.lineWidth = 1 / this.scale;
|
||||
|
||||
// Iterate through all bodies
|
||||
for (var body = world.getBodyList(); body; body = body.getNext()) {
|
||||
var transform = body.getTransform();
|
||||
|
||||
// Iterate through all fixtures
|
||||
for (var fixture = body.getFixtureList(); fixture; fixture = fixture.getNext()) {
|
||||
var shape = fixture.getShape();
|
||||
|
||||
if (body.isDynamic()) {
|
||||
this.ctx.strokeStyle = '#ff0000'; // Red for dynamic bodies
|
||||
this.ctx.fillStyle = 'rgba(255, 0, 0, 0.1)';
|
||||
} else if (body.isStatic()) {
|
||||
this.ctx.strokeStyle = '#00ff00'; // Green for static bodies
|
||||
this.ctx.fillStyle = 'rgba(0, 255, 0, 0.1)';
|
||||
} else {
|
||||
this.ctx.strokeStyle = '#0000ff'; // Blue for kinematic bodies
|
||||
this.ctx.fillStyle = 'rgba(0, 0, 255, 0.1)';
|
||||
}
|
||||
|
||||
this.drawShape(shape, transform);
|
||||
}
|
||||
}
|
||||
|
||||
this.ctx.restore();
|
||||
};
|
||||
|
||||
PlanckDebugDraw.prototype.drawShape = function(shape, transform) {
|
||||
var type = shape.getType();
|
||||
|
||||
if (type === 'circle') {
|
||||
this.drawCircle(shape, transform);
|
||||
} else if (type === 'polygon') {
|
||||
this.drawPolygon(shape, transform);
|
||||
} else if (type === 'edge') {
|
||||
this.drawEdge(shape, transform);
|
||||
} else if (type === 'chain') {
|
||||
this.drawChain(shape, transform);
|
||||
}
|
||||
};
|
||||
|
||||
PlanckDebugDraw.prototype.drawCircle = function(shape, transform) {
|
||||
var center = transform.p;
|
||||
var radius = shape.getRadius();
|
||||
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
|
||||
this.ctx.fill();
|
||||
this.ctx.stroke();
|
||||
|
||||
// Draw radius line to show rotation
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(center.x, center.y);
|
||||
this.ctx.lineTo(center.x + radius, center.y);
|
||||
this.ctx.stroke();
|
||||
};
|
||||
|
||||
PlanckDebugDraw.prototype.drawPolygon = function(shape, transform) {
|
||||
var vertices = shape.m_vertices;
|
||||
if (!vertices || vertices.length < 3) return;
|
||||
|
||||
this.ctx.beginPath();
|
||||
|
||||
// Transform first vertex
|
||||
var v = this.transformVertex(vertices[0], transform);
|
||||
this.ctx.moveTo(v.x, v.y);
|
||||
|
||||
// Transform and draw remaining vertices
|
||||
for (var i = 1; i < vertices.length; i++) {
|
||||
v = this.transformVertex(vertices[i], transform);
|
||||
this.ctx.lineTo(v.x, v.y);
|
||||
}
|
||||
|
||||
this.ctx.closePath();
|
||||
this.ctx.fill();
|
||||
this.ctx.stroke();
|
||||
};
|
||||
|
||||
PlanckDebugDraw.prototype.drawEdge = function(shape, transform) {
|
||||
var v1 = this.transformVertex(shape.m_vertex1, transform);
|
||||
var v2 = this.transformVertex(shape.m_vertex2, transform);
|
||||
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(v1.x, v1.y);
|
||||
this.ctx.lineTo(v2.x, v2.y);
|
||||
this.ctx.stroke();
|
||||
};
|
||||
|
||||
PlanckDebugDraw.prototype.drawChain = function(shape, transform) {
|
||||
var vertices = shape.m_vertices;
|
||||
if (!vertices || vertices.length < 2) return;
|
||||
|
||||
this.ctx.beginPath();
|
||||
|
||||
var v = this.transformVertex(vertices[0], transform);
|
||||
this.ctx.moveTo(v.x, v.y);
|
||||
|
||||
for (var i = 1; i < vertices.length; i++) {
|
||||
v = this.transformVertex(vertices[i], transform);
|
||||
this.ctx.lineTo(v.x, v.y);
|
||||
}
|
||||
|
||||
this.ctx.stroke();
|
||||
};
|
||||
|
||||
PlanckDebugDraw.prototype.transformVertex = function(vertex, transform) {
|
||||
// Apply transform: rotated_vertex = transform.q * vertex + transform.p
|
||||
var cos = Math.cos(transform.q.getAngle());
|
||||
var sin = Math.sin(transform.q.getAngle());
|
||||
|
||||
return {
|
||||
x: transform.p.x + (cos * vertex.x - sin * vertex.y),
|
||||
y: transform.p.y + (sin * vertex.x + cos * vertex.y)
|
||||
};
|
||||
};
|
||||
|
||||
PlanckDebugDraw.prototype.setFlags = function(flags) {
|
||||
this.flags = flags;
|
||||
};
|
||||
|
||||
return PlanckDebugDraw;
|
||||
|
||||
});
|
||||
|
|
@ -1,56 +1,52 @@
|
|||
define([
|
||||
"Lib/Vendor/Box2D"
|
||||
"Lib/Vendor/Planck"
|
||||
],
|
||||
|
||||
function (Box2D) {
|
||||
function (Planck) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function Detector () {
|
||||
this.listener = new Box2D.Dynamics.b2ContactListener();
|
||||
this.listener.BeginContact = this.beginContact.bind(this);
|
||||
//this.listener.PostSolve = this.postSolve.bind(this);
|
||||
this.listener.EndContact = this.endContact.bind(this);
|
||||
// In Planck.js, contact listeners are handled via world events
|
||||
// We'll store the world reference when getListener is called
|
||||
this.world = null;
|
||||
}
|
||||
|
||||
Detector.prototype.getListener = function () {
|
||||
return this.listener;
|
||||
// Instead of returning a listener object, we return a function
|
||||
// that will set up the event listeners on the world
|
||||
return this.setupWorldEvents.bind(this);
|
||||
}
|
||||
|
||||
Detector.prototype.onCollisionChange = function (point, isColliding) {
|
||||
var userDataA = point.GetFixtureA().GetUserData();
|
||||
var userDataB = point.GetFixtureB().GetUserData();
|
||||
Detector.prototype.setupWorldEvents = function (world) {
|
||||
this.world = world;
|
||||
|
||||
// Set up Planck.js event listeners
|
||||
world.on('begin-contact', this.beginContact.bind(this));
|
||||
world.on('end-contact', this.endContact.bind(this));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Detector.prototype.onCollisionChange = function (contact, isColliding) {
|
||||
var userDataA = contact.getFixtureA().getUserData();
|
||||
var userDataB = contact.getFixtureB().getUserData();
|
||||
|
||||
if (userDataA && userDataA.onCollisionChange) {
|
||||
userDataA.onCollisionChange(isColliding, point.GetFixtureB());
|
||||
userDataA.onCollisionChange(isColliding, contact.getFixtureB());
|
||||
}
|
||||
|
||||
if (userDataB && userDataB.onCollisionChange) {
|
||||
userDataB.onCollisionChange(isColliding, point.GetFixtureA());
|
||||
userDataB.onCollisionChange(isColliding, contact.getFixtureA());
|
||||
}
|
||||
}
|
||||
|
||||
/** Extension **/
|
||||
|
||||
Detector.prototype.beginContact = function (point) {
|
||||
this.onCollisionChange(point, true);
|
||||
Detector.prototype.beginContact = function (contact) {
|
||||
this.onCollisionChange(contact, true);
|
||||
}
|
||||
|
||||
/*
|
||||
Detector.prototype.postSolve = function (point, impulse) {
|
||||
var userDataA = point.GetFixtureA().GetUserData();
|
||||
var userDataB = point.GetFixtureB().GetUserData();
|
||||
|
||||
if (userDataA && userDataA.onImpulse) {
|
||||
userDataA.onImpulse(impulse, point.GetFixtureB());
|
||||
} else if (userDataB && userDataB.onImpulse) {
|
||||
userDataB.onImpulse(impulse, point.GetFixtureA());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Detector.prototype.endContact = function (point) {
|
||||
this.onCollisionChange(point, false);
|
||||
Detector.prototype.endContact = function (contact) {
|
||||
this.onCollisionChange(contact, false);
|
||||
}
|
||||
|
||||
return Detector;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
this.ragDoll = {head: null, body: null}; // FIXME: wtf is this? can we remove it?
|
||||
|
||||
this.createFixtures();
|
||||
this.body.SetActive(false);
|
||||
this.body.setActive(false);
|
||||
|
||||
nc.trigger(nc.ns.core.game.worldUpdateObjects.add, this);
|
||||
}
|
||||
|
|
@ -67,16 +67,16 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
var self = this;
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fixtureDef.density = Settings.PLAYER_DENSITY;
|
||||
fixtureDef.friction = 0;
|
||||
fixtureDef.restitution = Settings.PLAYER_RESTITUTION;
|
||||
|
||||
var headShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
var radius = this.width / 2 / Settings.RATIO;
|
||||
headShape.SetRadius(radius);
|
||||
|
||||
headShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0, -(this.height - (this.width / 2)) / Settings.RATIO));
|
||||
var headShape = planck.Circle(
|
||||
radius,
|
||||
planck.Vec2(0, -(this.height - (this.width / 2)) / Settings.RATIO)
|
||||
);
|
||||
fixtureDef.shape = headShape;
|
||||
fixtureDef.isSensor = false;
|
||||
fixtureDef.userData = {
|
||||
|
|
@ -85,19 +85,20 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
this.body.createFixture(fixtureDef);
|
||||
|
||||
var bodyShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
bodyShape.SetAsOrientedBox(
|
||||
var bodyShape = planck.Box(
|
||||
this.width / 2 / Settings.RATIO,
|
||||
(this.height - this.width) / 2 / Settings.RATIO,
|
||||
new Box2D.Common.Math.b2Vec2(0, -this.height / 2 / Settings.RATIO)
|
||||
planck.Vec2(0, -this.height / 2 / Settings.RATIO),
|
||||
0
|
||||
);
|
||||
fixtureDef.shape = bodyShape;
|
||||
fixtureDef.isSensor = false;
|
||||
this.body.createFixture(fixtureDef);
|
||||
|
||||
var legsShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
legsShape.SetRadius(this.width / 2 / Settings.RATIO);
|
||||
legsShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0, -this.width / 2 / Settings.RATIO));
|
||||
var legsShape = planck.Circle(
|
||||
this.width / 2 / Settings.RATIO,
|
||||
planck.Vec2(0, -this.width / 2 / Settings.RATIO)
|
||||
);
|
||||
fixtureDef.shape = legsShape;
|
||||
fixtureDef.friction = Settings.PLAYER_FRICTION;
|
||||
fixtureDef.isSensor = false;
|
||||
|
|
@ -106,9 +107,10 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
fixtureDef.density = 0;
|
||||
|
||||
var feetShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
feetShape.SetRadius((this.width - 1) / 2 / Settings.RATIO); // the -1 one prevents collisions with walls
|
||||
feetShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0, 2 / Settings.RATIO)); // 2 is offset into ground
|
||||
var feetShape = planck.Circle(
|
||||
(this.width - 1) / 2 / Settings.RATIO, // the -1 one prevents collisions with walls
|
||||
planck.Vec2(0, 2 / Settings.RATIO) // 2 is offset into ground
|
||||
);
|
||||
fixtureDef.shape = feetShape;
|
||||
fixtureDef.isSensor = true;
|
||||
|
||||
|
|
@ -118,11 +120,10 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
this.footSensor = this.body.createFixture(fixtureDef);
|
||||
|
||||
var grabSensorLeftShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
grabSensorLeftShape.SetAsOrientedBox(
|
||||
var grabSensorLeftShape = planck.Box(
|
||||
this.reachDistance / 2 / Settings.RATIO,
|
||||
((this.height / 2) + this.reachDistance / 4) / Settings.RATIO,
|
||||
new Box2D.Common.Math.b2Vec2(
|
||||
planck.Vec2(
|
||||
-this.reachDistance / 2 / Settings.RATIO,
|
||||
-this.height / 2 / Settings.RATIO
|
||||
)
|
||||
|
|
@ -136,11 +137,10 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
};
|
||||
this.body.createFixture(fixtureDef);
|
||||
|
||||
var grabSensorRightShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
grabSensorRightShape.SetAsOrientedBox(
|
||||
var grabSensorRightShape = planck.Box(
|
||||
this.reachDistance / 2 / Settings.RATIO,
|
||||
((this.height / 2) + this.reachDistance / 4) / Settings.RATIO,
|
||||
new Box2D.Common.Math.b2Vec2(
|
||||
planck.Vec2(
|
||||
this.reachDistance / 2 / Settings.RATIO,
|
||||
-this.height / 2 / Settings.RATIO
|
||||
)
|
||||
|
|
@ -157,11 +157,10 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
this.body.createFixture(fixtureDef);
|
||||
|
||||
// Area Sensor
|
||||
var areaSensorShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
areaSensorShape.SetAsOrientedBox(
|
||||
var areaSensorShape = planck.Box(
|
||||
(this.width + this.areaSize) / 2 / Settings.RATIO,
|
||||
(this.height + this.areaSize) / 2 / Settings.RATIO,
|
||||
new Box2D.Common.Math.b2Vec2(
|
||||
planck.Vec2(
|
||||
0,
|
||||
-this.height / 2 / Settings.RATIO
|
||||
)
|
||||
|
|
@ -171,7 +170,7 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
fixtureDef.userData = {
|
||||
onCollisionChange: function(isColliding, fixture) {
|
||||
var userData = fixture.GetBody().GetUserData();
|
||||
var userData = fixture.getBody().getUserData();
|
||||
if(userData instanceof Doll) {
|
||||
var doll = userData;
|
||||
var i = self.nearbyDolls.indexOf(doll);
|
||||
|
|
@ -205,13 +204,13 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
Doll.prototype.spawn = function (x, y) {
|
||||
Assert.number(x, y);
|
||||
this.body.SetPosition(new Box2D.Common.Math.b2Vec2(x / Settings.RATIO, y / Settings.RATIO));
|
||||
this.body.SetActive(true);
|
||||
this.body.setPosition(planck.Vec2(x / Settings.RATIO, y / Settings.RATIO));
|
||||
this.body.setActive(true);
|
||||
this.setActionState("fall");
|
||||
};
|
||||
|
||||
Doll.prototype.getHeadPosition = function() {
|
||||
var pos = this.body.GetPosition();
|
||||
var pos = this.body.getPosition();
|
||||
return {
|
||||
x: pos.x,
|
||||
y: pos.y - (this.height - this.headHeight / 2) / Settings.RATIO
|
||||
|
|
@ -255,11 +254,11 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
}
|
||||
|
||||
this.setFriction(Settings.PLAYER_MOTION_FRICTION);
|
||||
this.body.SetAwake(true);
|
||||
this.body.setAwake(true);
|
||||
|
||||
Assert.number(speed, direction);
|
||||
var vector = new Box2D.Common.Math.b2Vec2(speed * direction, this.body.GetLinearVelocity().y);
|
||||
this.body.SetLinearVelocity(vector);
|
||||
var vector = planck.Vec2(speed * direction, this.body.getLinearVelocity().y);
|
||||
this.body.setLinearVelocity(vector);
|
||||
|
||||
if(this.isStanding()) {
|
||||
if(this.moveDirection == this.lookDirection) {
|
||||
|
|
@ -282,19 +281,19 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
if(this.isStanding()) {
|
||||
this.setActionState("stand");
|
||||
} else {
|
||||
var vector = this.body.GetLinearVelocity().Copy();
|
||||
var vector = this.body.getLinearVelocity().clone();
|
||||
vector.x *= Settings.JUMP_STOP_DAMPING_FACTOR;
|
||||
this.body.SetLinearVelocity(vector);
|
||||
this.body.setLinearVelocity(vector);
|
||||
}
|
||||
};
|
||||
|
||||
Doll.prototype.jump = function () {
|
||||
if (this.isStanding()) {
|
||||
|
||||
this.body.SetAwake(true);
|
||||
this.body.setAwake(true);
|
||||
|
||||
var vector = new Box2D.Common.Math.b2Vec2(0, -Settings.JUMP_SPEED);
|
||||
this.body.SetLinearVelocity(vector);
|
||||
var vector = planck.Vec2(0, -Settings.JUMP_SPEED);
|
||||
this.body.setLinearVelocity(vector);
|
||||
|
||||
this.setStanding(false);
|
||||
this.setActionState("jump");
|
||||
|
|
@ -303,11 +302,11 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
Doll.prototype.jumpStop = function () {
|
||||
if (!this.isStanding() ) {
|
||||
this.body.SetAwake(true);
|
||||
var vector = this.body.GetLinearVelocity().Copy();
|
||||
this.body.setAwake(true);
|
||||
var vector = this.body.getLinearVelocity().clone();
|
||||
if(vector.y < 0) {
|
||||
vector.y *= Settings.JUMP_STOP_DAMPING_FACTOR;
|
||||
this.body.SetLinearVelocity(vector);
|
||||
this.body.setLinearVelocity(vector);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -325,7 +324,7 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
Doll.prototype.lookAt = function(x, y) {
|
||||
var oldLookDirection = this.lookDirection;
|
||||
|
||||
this.body.SetAwake(true);
|
||||
this.body.setAwake(true);
|
||||
if(x < 0) {
|
||||
this.lookDirection = -1;
|
||||
} else {
|
||||
|
|
@ -353,11 +352,11 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
this.holdingJoint = null;
|
||||
}
|
||||
|
||||
var bodyPosition = this.body.GetPosition();
|
||||
var bodyPosition = this.body.getPosition();
|
||||
|
||||
Assert.number(this.width, this.height);
|
||||
Assert.number(this.lookDirection);
|
||||
var handPosition = new Box2D.Common.Math.b2Vec2(
|
||||
var handPosition = planck.Vec2(
|
||||
bodyPosition.x + ((this.width / 2 / Settings.RATIO) * this.lookDirection),
|
||||
bodyPosition.y - this.height / 4 * 2 / Settings.RATIO // 2/3 of the body height
|
||||
);
|
||||
|
|
@ -384,8 +383,8 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
this.holdingItem = null;
|
||||
|
||||
var dollVelocity = {
|
||||
x: this.body.GetLinearVelocity().x,
|
||||
y: this.body.GetLinearVelocity().y
|
||||
x: this.body.getLinearVelocity().x,
|
||||
y: this.body.getLinearVelocity().y
|
||||
};
|
||||
|
||||
item.throw(options, dollVelocity);
|
||||
|
|
@ -399,7 +398,7 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
var self = this;
|
||||
|
||||
var hasJumpStartVelocity = this.body.GetLinearVelocity().y < -Settings.JUMP_SPEED;
|
||||
var hasJumpStartVelocity = this.body.getLinearVelocity().y < -Settings.JUMP_SPEED;
|
||||
|
||||
if(isColliding) {
|
||||
if(!hasJumpStartVelocity) {
|
||||
|
|
@ -417,11 +416,11 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
continue;
|
||||
}
|
||||
|
||||
if(contact.GetFixtureA() === self.footSensor) {
|
||||
if(contact.getFixtureA() === self.footSensor) {
|
||||
contactCount++;
|
||||
}
|
||||
|
||||
if(contact.GetFixtureB() === self.footSensor) {
|
||||
if(contact.getFixtureB() === self.footSensor) {
|
||||
contactCount++;
|
||||
}
|
||||
|
||||
|
|
@ -439,7 +438,7 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
};
|
||||
|
||||
Doll.prototype.onFixtureWithinReach = function(isColliding, side, fixture) {
|
||||
var item = fixture.GetBody().GetUserData();
|
||||
var item = fixture.getBody().getUserData();
|
||||
if (!(item instanceof Item)) return;
|
||||
|
||||
if(isColliding) {
|
||||
|
|
@ -456,18 +455,18 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse
|
|||
|
||||
Doll.prototype.getVelocities = function() {
|
||||
return {
|
||||
linearVelocity: this.body.GetLinearVelocity(),
|
||||
angularVelocity: this.body.GetAngularVelocity()
|
||||
linearVelocity: this.body.getLinearVelocity(),
|
||||
angularVelocity: this.body.getAngularVelocity()
|
||||
};
|
||||
};
|
||||
|
||||
Doll.prototype.update = function() {
|
||||
|
||||
if (this.body.GetLinearVelocity().x === 0 && this.isWalking()) {
|
||||
if (this.body.getLinearVelocity().x === 0 && this.isWalking()) {
|
||||
this.stop();
|
||||
}
|
||||
|
||||
if (!this.body.IsAwake() && !this.isStanding()) {
|
||||
if (!this.body.isAwake() && !this.isStanding()) {
|
||||
this.setStanding(true);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ function (planck, Exception, Assert, nc) {
|
|||
Assert.number(update.lv.x, update.lv.y);
|
||||
Assert.number(update.av);
|
||||
|
||||
this.body.SetAwake(true);
|
||||
this.body.SetPosition(update.p);
|
||||
this.body.SetAngle(update.a);
|
||||
this.body.SetLinearVelocity(update.lv);
|
||||
this.body.SetAngularVelocity(update.av);
|
||||
this.body.setAwake(true);
|
||||
this.body.setPosition(update.p);
|
||||
this.body.setAngle(update.a);
|
||||
this.body.setLinearVelocity(update.lv);
|
||||
this.body.setAngularVelocity(update.av);
|
||||
};
|
||||
|
||||
return GameObject;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/" + GLOBALS.context + "/GameObjects/GameObject",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Lib/Utilities/OptionsHelper",
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/Exception",
|
||||
|
|
@ -37,7 +37,7 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
|||
this.createFixture();
|
||||
this.body.ResetMassData();
|
||||
this.flipDirection = 1;
|
||||
if (this.body.GetMass() < 1) {
|
||||
if (this.body.getMass() < 1) {
|
||||
this.body.SetBullet(true);
|
||||
}
|
||||
|
||||
|
|
@ -48,11 +48,11 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
|||
|
||||
Item.prototype.getBodyDef = function() {
|
||||
Assert.number(this.options.x, this.options.y);
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
bodyDef.position.x = this.options.x / Settings.RATIO;
|
||||
bodyDef.position.y = this.options.y / Settings.RATIO;
|
||||
bodyDef.angle = 0;
|
||||
var bodyDef = {
|
||||
type: 'dynamic',
|
||||
position: planck.Vec2(this.options.x / Settings.RATIO, this.options.y / Settings.RATIO),
|
||||
angle: 0
|
||||
};
|
||||
|
||||
return bodyDef;
|
||||
};
|
||||
|
|
@ -68,15 +68,12 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
|||
|
||||
if(this.options.type == "circle") {
|
||||
var r = (w + h) / 4 ;
|
||||
itemShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
itemShape.SetRadius(r);
|
||||
itemShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0, -r));
|
||||
itemShape = planck.Circle(r, planck.Vec2(0, -r));
|
||||
} else {
|
||||
itemShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
itemShape.SetAsOrientedBox(w / 2, h / 2, new Box2D.Common.Math.b2Vec2(0, -(h/2)));
|
||||
itemShape = planck.Box(w / 2, h / 2, planck.Vec2(0, -(h/2)));
|
||||
}
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fixtureDef.shape = itemShape;
|
||||
|
||||
fixtureDef.density = this.options.weight;
|
||||
|
|
@ -95,7 +92,7 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
|||
|
||||
Item.prototype.createFixture = function () {
|
||||
var fixtureDef = this.getFixtureDef();
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
this.body.createFixture(fixtureDef);
|
||||
};
|
||||
|
||||
Item.prototype.flip = function(direction) {
|
||||
|
|
@ -122,8 +119,8 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
|||
Assert.number(this.options.width);
|
||||
Assert.number(this.options.grabAngle);
|
||||
|
||||
this.body.SetAwake(true);
|
||||
var position = new Box2D.Common.Math.b2Vec2(
|
||||
this.body.setAwake(true);
|
||||
var position = planck.Vec2(
|
||||
handPosition.x + ((this.options.width / Settings.RATIO / 2) * direction),
|
||||
handPosition.y
|
||||
);
|
||||
|
|
@ -133,7 +130,7 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
|||
};
|
||||
|
||||
Item.prototype.getGrabPoint = function() {
|
||||
return this.body.GetWorldCenter();
|
||||
return this.body.getWorldCenter();
|
||||
};
|
||||
|
||||
Item.prototype.throw = function(options, carrierVelocity) {
|
||||
|
|
@ -146,15 +143,15 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
|||
Assert.number(options.x, options.y);
|
||||
Assert.number(options.av);
|
||||
|
||||
body.SetAwake(true);
|
||||
body.setAwake(true);
|
||||
|
||||
var x = options.x * Settings.MAX_THROW_FORCE / this.options.weight + carrierVelocity.x;
|
||||
var y = -options.y * Settings.MAX_THROW_FORCE / this.options.weight + carrierVelocity.y;
|
||||
var vector = new Box2D.Common.Math.b2Vec2(x, y);
|
||||
var vector = planck.Vec2(x, y);
|
||||
body.SetLinearVelocity(vector);
|
||||
|
||||
var av = -options.av * Settings.MAX_THROW_ANGULAR_VELOCITY;
|
||||
body.SetAngularVelocity(av);
|
||||
body.setAngularVelocity(av);
|
||||
};
|
||||
|
||||
Item.prototype.destroy = function() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Lib/Utilities/Assert",
|
||||
|
|
@ -174,17 +174,17 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
};
|
||||
|
||||
RagDoll.prototype.getPosition = function() {
|
||||
return this.body.GetPosition().Copy();
|
||||
return this.body.GetPosition().clone();
|
||||
};
|
||||
|
||||
RagDoll.prototype.getHeadPosition = function() {
|
||||
return this.limbs.head.GetPosition().Copy();
|
||||
return this.limbs.head.GetPosition().clone();
|
||||
};
|
||||
|
||||
RagDoll.prototype.getBodyDef = function() {
|
||||
var bodyDef = Parent.prototype.getBodyDef.call(this);
|
||||
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
bodyDef.type = 'dynamic';
|
||||
bodyDef.position.y -= this.options.height / 2 / Settings.RATIO; // position it on top of ground
|
||||
|
||||
return bodyDef;
|
||||
|
|
@ -199,11 +199,10 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
fixtureDef.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fixtureDef.filter.groupIndex = -this.getId();
|
||||
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
shape.SetAsOrientedBox(
|
||||
var shape = planck.Box(
|
||||
this.options.limbs.chest.width / 2 / Settings.RATIO,
|
||||
this.options.limbs.chest.height / 2 / Settings.RATIO,
|
||||
new Box2D.Common.Math.b2Vec2(0, 0)
|
||||
planck.Vec2(0, 0)
|
||||
);
|
||||
|
||||
fixtureDef.shape = shape;
|
||||
|
|
@ -217,10 +216,9 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
var w = this.options.width / Settings.RATIO;
|
||||
var h = this.options.height / Settings.RATIO;
|
||||
|
||||
var itemShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
itemShape.SetAsOrientedBox(w / 2, h / 2, new Box2D.Common.Math.b2Vec2(0, 0));
|
||||
var itemShape = planck.Box(w / 2, h / 2, planck.Vec2(0, 0));
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fixtureDef.shape = itemShape;
|
||||
fixtureDef.isSensor = true;
|
||||
|
||||
|
|
@ -228,7 +226,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
onCollisionChange: this.onCollisionChange.bind(this)
|
||||
};
|
||||
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
this.body.createFixture(fixtureDef);
|
||||
};
|
||||
|
||||
RagDoll.prototype.addHead = function() {
|
||||
|
|
@ -239,17 +237,15 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
var x = this.options.x + this.options.limbs.head.x,
|
||||
y = this.options.y + this.options.limbs.head.y - this.options.height / 2; // position it on top of ground;
|
||||
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
bodyDef.position.x = x / Settings.RATIO;
|
||||
bodyDef.position.y = y / Settings.RATIO;
|
||||
bodyDef.angle = 0;
|
||||
var bodyDef = {
|
||||
type: 'dynamic',
|
||||
position: planck.Vec2(x / Settings.RATIO, y / Settings.RATIO),
|
||||
angle: 0
|
||||
};
|
||||
|
||||
var shape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
shape.SetRadius(this.options.limbs.head.width / 2 / Settings.RATIO);
|
||||
shape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0, 0));
|
||||
var shape = planck.Circle(this.options.limbs.head.width / 2 / Settings.RATIO, planck.Vec2(0, 0));
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fixtureDef.density = Settings.PLAYER_DENSITY;
|
||||
fixtureDef.friction = Settings.PLAYER_FRICTION;
|
||||
fixtureDef.restitution = Settings.PLAYER_RESTITUTION;
|
||||
|
|
@ -258,7 +254,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
fixtureDef.filter.groupIndex = -this.getId();
|
||||
|
||||
var head = this.body.GetWorld().CreateBody(bodyDef);
|
||||
head.CreateFixture(fixtureDef);
|
||||
head.createFixture(fixtureDef);
|
||||
|
||||
this.limbs.head = head;
|
||||
|
||||
|
|
@ -271,7 +267,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
var jointDef = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
|
||||
jointDef.enableMotor = false;
|
||||
|
||||
var pos = this.body.GetWorldCenter().Copy();
|
||||
var pos = this.body.getWorldCenter().clone();
|
||||
pos.y -= this.options.limbs.chest.height / 2 / Settings.RATIO;
|
||||
jointDef.Initialize(this.body, head, pos);
|
||||
jointDef.lowerAngle = -0.25 * Box2D.Common.b2Settings.b2_pi; // -45 degrees
|
||||
|
|
@ -290,21 +286,20 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
var x = this.options.x + this.options.limbs[name].x,
|
||||
y = this.options.y + this.options.limbs[name].y - this.options.height / 2; // position it on top of ground;;
|
||||
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
bodyDef.position.x = x / Settings.RATIO;
|
||||
bodyDef.position.y = y / Settings.RATIO;
|
||||
bodyDef.angle = 0;
|
||||
var bodyDef = {
|
||||
type: 'dynamic',
|
||||
position: planck.Vec2(x / Settings.RATIO, y / Settings.RATIO),
|
||||
angle: 0,
|
||||
linearDamping: Settings.PLAYER_LINEAR_DAMPING
|
||||
};
|
||||
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
shape.SetAsOrientedBox(
|
||||
var shape = planck.Box(
|
||||
this.options.limbs[name].width / 2 / Settings.RATIO,
|
||||
this.options.limbs[name].height / 2 / Settings.RATIO,
|
||||
new Box2D.Common.Math.b2Vec2(0, this.options.limbs[name].height / 2 / Settings.RATIO)
|
||||
planck.Vec2(0, this.options.limbs[name].height / 2 / Settings.RATIO)
|
||||
);
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fixtureDef.density = Settings.PLAYER_DENSITY;
|
||||
fixtureDef.friction = Settings.PLAYER_FRICTION;
|
||||
fixtureDef.restitution = Settings.PLAYER_RESTITUTION;
|
||||
|
|
@ -313,14 +308,14 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
fixtureDef.filter.groupIndex = -this.getId();
|
||||
|
||||
var limb = this.body.GetWorld().CreateBody(bodyDef);
|
||||
limb.CreateFixture(fixtureDef);
|
||||
limb.createFixture(fixtureDef);
|
||||
|
||||
this.limbs[name] = limb;
|
||||
|
||||
var jointDef = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
|
||||
jointDef.enableMotor = false;
|
||||
|
||||
var pos = connectTo.GetWorldCenter().Copy();
|
||||
var pos = connectTo.getWorldCenter().clone();
|
||||
pos.x += (xOffset / Settings.RATIO);
|
||||
pos.y += (yOffset / Settings.RATIO);
|
||||
jointDef.Initialize(connectTo, limb, pos);
|
||||
|
|
@ -347,7 +342,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
|
||||
var chestPosition = this.body.GetPosition();
|
||||
|
||||
var position = new Box2D.Common.Math.b2Vec2(
|
||||
var position = planck.Vec2(
|
||||
chestPosition.x + this.options.limbs.head.x / Settings.RATIO,
|
||||
chestPosition.y + this.options.limbs.head.y / Settings.RATIO
|
||||
);
|
||||
|
|
@ -370,7 +365,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
|||
Assert.number(options.angularVelocity);
|
||||
|
||||
this.body.SetLinearVelocity(options.linearVelocity);
|
||||
this.body.SetAngularVelocity(options.angularVelocity);
|
||||
this.body.setAngularVelocity(options.angularVelocity);
|
||||
for(var name in this.limbs) {
|
||||
this.limbs[name].SetLinearVelocity(options.linearVelocity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Game/Config/Settings"
|
||||
],
|
||||
|
||||
|
|
@ -24,13 +24,13 @@ function (Parent, Box2D, Settings) {
|
|||
var bodies = [];
|
||||
var joints = [];
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(-1.917114257812500e-01, 1.433728694915771e+00);
|
||||
bodies[0] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -38,45 +38,45 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(6.299880146980286e-02, -2.545155882835388e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(6.299880146980286e-02, 2.545149326324463e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-6.299890577793121e-02, 2.545149326324463e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-6.299890577793121e-02, -2.545155882835388e-01);
|
||||
vs[0] = planck.Vec2(6.299880146980286e-02, -2.545155882835388e-01);
|
||||
vs[1] = planck.Vec2(6.299880146980286e-02, 2.545149326324463e-01);
|
||||
vs[2] = planck.Vec2(-6.299890577793121e-02, 2.545149326324463e-01);
|
||||
vs[3] = planck.Vec2(-6.299890577793121e-02, -2.545155882835388e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[0].CreateFixture(fd);
|
||||
bodies[0].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(-6.397294998168945e-02, 1.267420768737793e+00);
|
||||
bodies[1] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(1.883362084627151e-01, -4.305148720741272e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(1.846363544464111e-01, 5.393795371055603e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(1.850083470344543e-03, 5.393795371055603e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-1.883361339569092e-01, 4.209862351417542e-01);
|
||||
vs[4] = new Box2D.Common.Math.b2Vec2(-1.883361339569092e-01, -4.607573151588440e-01);
|
||||
vs[5] = new Box2D.Common.Math.b2Vec2(1.600667834281921e-03, -4.952520132064819e-01);
|
||||
vs[0] = planck.Vec2(1.883362084627151e-01, -4.305148720741272e-01);
|
||||
vs[1] = planck.Vec2(1.846363544464111e-01, 5.393795371055603e-01);
|
||||
vs[2] = planck.Vec2(1.850083470344543e-03, 5.393795371055603e-01);
|
||||
vs[3] = planck.Vec2(-1.883361339569092e-01, 4.209862351417542e-01);
|
||||
vs[4] = planck.Vec2(-1.883361339569092e-01, -4.607573151588440e-01);
|
||||
vs[5] = planck.Vec2(1.600667834281921e-03, -4.952520132064819e-01);
|
||||
shape.SetAsArray(vs, 6);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[1].CreateFixture(fd);
|
||||
bodies[1].createFixture(fd);
|
||||
}
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -84,25 +84,25 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(1.840525716543198e-01, 4.875739216804504e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(1.840525716543198e-01, 6.762337088584900e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-4.607129842042923e-03, 6.762337088584900e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-4.607129842042923e-03, 4.875739216804504e-01);
|
||||
vs[0] = planck.Vec2(1.840525716543198e-01, 4.875739216804504e-01);
|
||||
vs[1] = planck.Vec2(1.840525716543198e-01, 6.762337088584900e-01);
|
||||
vs[2] = planck.Vec2(-4.607129842042923e-03, 6.762337088584900e-01);
|
||||
vs[3] = planck.Vec2(-4.607129842042923e-03, 4.875739216804504e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[1].CreateFixture(fd);
|
||||
bodies[1].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(4.118728637695312e-02, 2.199305295944214e+00);
|
||||
bodies[2] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = 2.000000029802322e-01;
|
||||
fd.restitution = 0.000000000000000e+00;
|
||||
fd.density = 2.204959988594055e-01;
|
||||
|
|
@ -114,10 +114,10 @@ function (Parent, Box2D, Settings) {
|
|||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[2].CreateFixture(fd);
|
||||
bodies[2].createFixture(fd);
|
||||
}
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = 2.000000029802322e-01;
|
||||
fd.restitution = 0.000000000000000e+00;
|
||||
fd.density = 2.204959988594055e-01;
|
||||
|
|
@ -129,17 +129,17 @@ function (Parent, Box2D, Settings) {
|
|||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[2].CreateFixture(fd);
|
||||
bodies[2].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(1.235442161560059e-01, 1.142371892929077e+00);
|
||||
bodies[3] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -147,26 +147,26 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(6.299892067909241e-02, -1.556134223937988e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(6.299892067909241e-02, 1.556134223937988e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-6.299898028373718e-02, 1.556134223937988e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-6.299898028373718e-02, -1.556134223937988e-01);
|
||||
vs[0] = planck.Vec2(6.299892067909241e-02, -1.556134223937988e-01);
|
||||
vs[1] = planck.Vec2(6.299892067909241e-02, 1.556134223937988e-01);
|
||||
vs[2] = planck.Vec2(-6.299898028373718e-02, 1.556134223937988e-01);
|
||||
vs[3] = planck.Vec2(-6.299898028373718e-02, -1.556134223937988e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[3].CreateFixture(fd);
|
||||
bodies[3].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(-9.663248062133789e-02, 3.554300665855408e-01);
|
||||
|
||||
bodies[4] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -174,18 +174,18 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(1.550966501235962e-01, -1.253567039966583e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(1.550966501235962e-01, -6.225190684199333e-02);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-9.268096834421158e-02, -6.225190684199333e-02);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-9.268096834421158e-02, -1.253567039966583e-01);
|
||||
vs[0] = planck.Vec2(1.550966501235962e-01, -1.253567039966583e-01);
|
||||
vs[1] = planck.Vec2(1.550966501235962e-01, -6.225190684199333e-02);
|
||||
vs[2] = planck.Vec2(-9.268096834421158e-02, -6.225190684199333e-02);
|
||||
vs[3] = planck.Vec2(-9.268096834421158e-02, -1.253567039966583e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[4].CreateFixture(fd);
|
||||
bodies[4].createFixture(fd);
|
||||
}
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -193,26 +193,26 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(9.449840337038040e-02, -1.247676759958267e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(9.449840337038040e-02, 1.715210527181625e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-9.449829906225204e-02, 1.715210527181625e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-9.449829906225204e-02, -1.247676759958267e-01);
|
||||
vs[0] = planck.Vec2(9.449840337038040e-02, -1.247676759958267e-01);
|
||||
vs[1] = planck.Vec2(9.449840337038040e-02, 1.715210527181625e-01);
|
||||
vs[2] = planck.Vec2(-9.449829906225204e-02, 1.715210527181625e-01);
|
||||
vs[3] = planck.Vec2(-9.449829906225204e-02, -1.247676759958267e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[4].CreateFixture(fd);
|
||||
bodies[4].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(-1.917138099670410e-01, 1.142371892929077e+00);
|
||||
|
||||
bodies[5] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -220,26 +220,26 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(6.299891322851181e-02, -1.556134223937988e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(6.299891322851181e-02, 1.556134223937988e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-6.299878656864166e-02, 1.556134223937988e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-6.299878656864166e-02, -1.556134223937988e-01);
|
||||
vs[0] = planck.Vec2(6.299891322851181e-02, -1.556134223937988e-01);
|
||||
vs[1] = planck.Vec2(6.299891322851181e-02, 1.556134223937988e-01);
|
||||
vs[2] = planck.Vec2(-6.299878656864166e-02, 1.556134223937988e-01);
|
||||
vs[3] = planck.Vec2(-6.299878656864166e-02, -1.556134223937988e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[5].CreateFixture(fd);
|
||||
bodies[5].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(1.235442161560059e-01, 1.433728694915771e+00);
|
||||
|
||||
bodies[6] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -247,25 +247,25 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(6.299892067909241e-02, -2.545155882835388e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(6.299892067909241e-02, 2.545149326324463e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-6.299898028373718e-02, 2.545149326324463e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-6.299898028373718e-02, -2.545155882835388e-01);
|
||||
vs[0] = planck.Vec2(6.299892067909241e-02, -2.545155882835388e-01);
|
||||
vs[1] = planck.Vec2(6.299892067909241e-02, 2.545149326324463e-01);
|
||||
vs[2] = planck.Vec2(-6.299898028373718e-02, 2.545149326324463e-01);
|
||||
vs[3] = planck.Vec2(-6.299898028373718e-02, -2.545155882835388e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[6].CreateFixture(fd);
|
||||
bodies[6].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(2.897095680236816e-02, 6.702435612678528e-01);
|
||||
bodies[7] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -273,26 +273,26 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(9.449830651283264e-02, -2.537839412689209e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(9.449830651283264e-02, 2.537844777107239e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-9.449817240238190e-02, 2.537844777107239e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-9.449817240238190e-02, -2.537839412689209e-01);
|
||||
vs[0] = planck.Vec2(9.449830651283264e-02, -2.537839412689209e-01);
|
||||
vs[1] = planck.Vec2(9.449830651283264e-02, 2.537844777107239e-01);
|
||||
vs[2] = planck.Vec2(-9.449817240238190e-02, 2.537844777107239e-01);
|
||||
vs[3] = planck.Vec2(-9.449817240238190e-02, -2.537839412689209e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[7].CreateFixture(fd);
|
||||
bodies[7].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(-9.663248062133789e-02, 6.702435612678528e-01);
|
||||
|
||||
bodies[8] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -300,26 +300,26 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(9.449842572212219e-02, -2.537839412689209e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(9.449842572212219e-02, 2.537844777107239e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-9.449826925992966e-02, 2.537844777107239e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-9.449826925992966e-02, -2.537839412689209e-01);
|
||||
vs[0] = planck.Vec2(9.449842572212219e-02, -2.537839412689209e-01);
|
||||
vs[1] = planck.Vec2(9.449842572212219e-02, 2.537844777107239e-01);
|
||||
vs[2] = planck.Vec2(-9.449826925992966e-02, 2.537844777107239e-01);
|
||||
vs[3] = planck.Vec2(-9.449826925992966e-02, -2.537839412689209e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[8].CreateFixture(fd);
|
||||
bodies[8].createFixture(fd);
|
||||
}
|
||||
}
|
||||
{
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = 'dynamic';
|
||||
bd.position.Set(2.897095680236816e-02, 3.554300665855408e-01);
|
||||
|
||||
bodies[9] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -327,18 +327,18 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(1.550965905189514e-01, -1.253567039966583e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(1.550965905189514e-01, -6.225190684199333e-02);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-9.268099069595337e-02, -6.225190684199333e-02);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-9.268099069595337e-02, -1.253567039966583e-01);
|
||||
vs[0] = planck.Vec2(1.550965905189514e-01, -1.253567039966583e-01);
|
||||
vs[1] = planck.Vec2(1.550965905189514e-01, -6.225190684199333e-02);
|
||||
vs[2] = planck.Vec2(-9.268099069595337e-02, -6.225190684199333e-02);
|
||||
vs[3] = planck.Vec2(-9.268099069595337e-02, -1.253567039966583e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[9].CreateFixture(fd);
|
||||
bodies[9].createFixture(fd);
|
||||
}
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -346,29 +346,29 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = -1;
|
||||
var shape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var vs = [];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(9.449830651283264e-02, -1.247680261731148e-01);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(9.449830651283264e-02, 1.713046580553055e-01);
|
||||
vs[2] = new Box2D.Common.Math.b2Vec2(-9.449817240238190e-02, 1.713046580553055e-01);
|
||||
vs[3] = new Box2D.Common.Math.b2Vec2(-9.449817240238190e-02, -1.247680261731148e-01);
|
||||
vs[0] = planck.Vec2(9.449830651283264e-02, -1.247680261731148e-01);
|
||||
vs[1] = planck.Vec2(9.449830651283264e-02, 1.713046580553055e-01);
|
||||
vs[2] = planck.Vec2(-9.449817240238190e-02, 1.713046580553055e-01);
|
||||
vs[3] = planck.Vec2(-9.449817240238190e-02, -1.247680261731148e-01);
|
||||
shape.SetAsArray(vs, 4);
|
||||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[9].CreateFixture(fd);
|
||||
bodies[9].createFixture(fd);
|
||||
}
|
||||
}
|
||||
/*{
|
||||
|
||||
ground body
|
||||
|
||||
var bd = new Box2D.Dynamics.b2BodyDef();
|
||||
var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bd.type = b2BodyType(0);
|
||||
bd.position.Set(3.118395805358887e-03, -6.553649902343750e-03);
|
||||
|
||||
bodies[10] = world.CreateBody(bd);
|
||||
|
||||
{
|
||||
var fd = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fd.friction = Settings.PLAYER_FRICTION;
|
||||
fd.restitution = Settings.PLAYER_RESTITUTION;
|
||||
fd.density = Settings.PLAYER_DENSITY;
|
||||
|
|
@ -376,8 +376,8 @@ function (Parent, Box2D, Settings) {
|
|||
fd.filter.groupIndex = int16(0);
|
||||
b2ChainShape shape;
|
||||
b2Vec2 vs[2];
|
||||
vs[0] = new Box2D.Common.Math.b2Vec2(-4.179394245147705e+00, 0.000000000000000e+00);
|
||||
vs[1] = new Box2D.Common.Math.b2Vec2(4.179394245147705e+00, 0.000000000000000e+00);
|
||||
vs[0] = planck.Vec2(-4.179394245147705e+00, 0.000000000000000e+00);
|
||||
vs[1] = planck.Vec2(4.179394245147705e+00, 0.000000000000000e+00);
|
||||
shape.CreateChain(vs, 2);
|
||||
shape.m_prevVertex.Set(-1.998532295227051e+00, -2.391039296991059e-23);
|
||||
shape.m_nextVertex.Set(4.949933242915726e-38, 3.363116314379561e-44);
|
||||
|
|
@ -386,7 +386,7 @@ function (Parent, Box2D, Settings) {
|
|||
|
||||
fd.shape = shape;
|
||||
|
||||
bodies[10].CreateFixture(fd);
|
||||
bodies[10].createFixture(fd);
|
||||
}
|
||||
}*/
|
||||
{
|
||||
|
|
@ -548,7 +548,7 @@ function (Parent, Box2D, Settings) {
|
|||
lowerRightLeg: bodies[9]
|
||||
};
|
||||
|
||||
this.body.SetPosition(new Box2D.Common.Math.b2Vec2(20,0));
|
||||
this.body.SetPosition(planck.Vec2(20,0));
|
||||
};
|
||||
|
||||
RagDoll.prototype.destroy = function() {
|
||||
|
|
|
|||
|
|
@ -1,21 +1,25 @@
|
|||
define([
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||
"Lib/Vendor/RubeLoader",
|
||||
"Lib/Vendor/Box2D",
|
||||
// "Lib/Vendor/RubeLoader", // Temporarily disabled during Planck.js migration
|
||||
"Lib/Vendor/Planck",
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/Assert",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Lib/Utilities/Matrix",
|
||||
"json!Game/Asset/RubeDoll.json" // using requirejs json loader plugin
|
||||
"Lib/Utilities/Matrix"
|
||||
// "json!Game/Asset/RubeDoll.json" // Temporarily disabled during Planck.js migration
|
||||
],
|
||||
|
||||
function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson) {
|
||||
function (Parent, /* RubeLoader, */ Box2D, Settings, Assert, nc, Matrix /* , RubeDollJson */) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function RubeDoll(physicsEngine, uid, options) {
|
||||
Assert.number(options.x, options.y);
|
||||
|
||||
// TODO: Implement RubeDoll with Planck.js
|
||||
// Temporarily stubbed out during Box2D -> Planck.js migration
|
||||
console.warn("RubeDoll is temporarily disabled during Planck.js migration");
|
||||
|
||||
this.rubeLoader = null;
|
||||
this.body = null;
|
||||
this.limbs = {};
|
||||
|
|
@ -23,9 +27,8 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson)
|
|||
this.limits = [];
|
||||
|
||||
var chest = null;
|
||||
this.rubeLoader = new RubeLoader(RubeDollJson, physicsEngine.getWorldForRubeLoader());
|
||||
|
||||
this.loadRubeDollFromScene(options);
|
||||
// this.rubeLoader = new RubeLoader(RubeDollJson, physicsEngine.getWorldForRubeLoader());
|
||||
// this.loadRubeDollFromScene(options);
|
||||
|
||||
Parent.call(this, physicsEngine, uid, options);
|
||||
physicsEngine.destroyBody(this.body);
|
||||
|
|
@ -46,8 +49,8 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson)
|
|||
|
||||
for (var i in scene.bodies) {
|
||||
var body = scene.bodies[i];
|
||||
var position = body.GetPosition().Copy();
|
||||
position.Add(new Box2D.Common.Math.b2Vec2(
|
||||
var position = body.GetPosition().clone();
|
||||
position.Add(planck.Vec2(
|
||||
options.x / Settings.RATIO,
|
||||
options.y / Settings.RATIO
|
||||
));
|
||||
|
|
@ -86,7 +89,7 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson)
|
|||
};
|
||||
|
||||
RubeDoll.prototype.getFixtureDef = function() {
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fixtureDef.shape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
return fixtureDef;
|
||||
};
|
||||
|
|
@ -134,7 +137,7 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson)
|
|||
|
||||
var differenceAngle = oldAngle - this.body.GetAngle();
|
||||
|
||||
//this.body.SetLinearVelocity(new Box2D.Common.Math.b2Vec2(0, 0));
|
||||
//this.body.SetLinearVelocity(planck.Vec2(0, 0));
|
||||
|
||||
var offset = Box2D.Common.Math.b2Math.SubtractVV(this.getPosition(), oldPosition);
|
||||
var grabAngle = (this.options.grabAngle || 0.001);
|
||||
|
|
@ -143,12 +146,12 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson)
|
|||
var limb = this.limbs[key];
|
||||
|
||||
// Setting position offset first (floor to hand)
|
||||
var position = limb.GetPosition().Copy();
|
||||
var position = limb.GetPosition().clone();
|
||||
position.Add(offset);
|
||||
limb.SetPosition(position);
|
||||
|
||||
// grabing local point to "rotate" around (x, y position transform only)
|
||||
var localPoint = this.body.GetLocalPoint(limb.GetPosition().Copy());
|
||||
var localPoint = this.body.getLocalPoint(limb.GetPosition().clone());
|
||||
|
||||
// create rotation matrix from chest rotation difference
|
||||
var mat = Box2D.Common.Math.b2Mat22.FromAngle(differenceAngle);
|
||||
|
|
@ -157,15 +160,15 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson)
|
|||
position = Box2D.Common.Math.b2Math.MulTMV(mat, localPoint);
|
||||
|
||||
// translating back to global position
|
||||
var globalPoint = this.body.GetWorldPoint(position);
|
||||
var globalPoint = this.body.getWorldPoint(position);
|
||||
limb.SetPosition(globalPoint);
|
||||
|
||||
// relative limb rotating by chest rotation difference
|
||||
var d = (oldDirection == direction) ? -1 : 1;
|
||||
limb.SetAngle((limb.GetAngle() - differenceAngle) * d);
|
||||
|
||||
//limb.SetType(Box2D.Dynamics.b2Body.b2_staticBody);
|
||||
//limb.SetLinearVelocity(new Box2D.Common.Math.b2Vec2(0, 0));
|
||||
//limb.SetType('static');
|
||||
//limb.SetLinearVelocity(planck.Vec2(0, 0));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -174,18 +177,18 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson)
|
|||
Assert.number(options.angularVelocity);
|
||||
|
||||
this.body.SetLinearVelocity(options.linearVelocity);
|
||||
this.body.SetAngularVelocity(options.angularVelocity);
|
||||
this.body.setAngularVelocity(options.angularVelocity);
|
||||
for(var name in this.limbs) {
|
||||
this.limbs[name].SetLinearVelocity(options.linearVelocity);
|
||||
}
|
||||
};
|
||||
|
||||
RubeDoll.prototype.getPosition = function() {
|
||||
return this.body.GetPosition().Copy();
|
||||
return this.body.GetPosition().clone();
|
||||
};
|
||||
|
||||
RubeDoll.prototype.getHeadPosition = function() {
|
||||
return this.limbs.head.GetPosition().Copy();
|
||||
return this.limbs.head.GetPosition().clone();
|
||||
};
|
||||
|
||||
RubeDoll.prototype.setUpdateData = function(update) {
|
||||
|
|
@ -199,11 +202,11 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson)
|
|||
Assert.number(update.limbs[name].lv.x, update.limbs[name].lv.y);
|
||||
Assert.number(update.limbs[name].av);
|
||||
|
||||
this.limbs[name].SetAwake(true);
|
||||
this.limbs[name].setAwake(true);
|
||||
this.limbs[name].SetPosition(update.limbs[name].p);
|
||||
this.limbs[name].SetAngle(update.limbs[name].a);
|
||||
this.limbs[name].SetLinearVelocity(update.limbs[name].lv);
|
||||
this.limbs[name].SetAngularVelocity(update.limbs[name].av);
|
||||
this.limbs[name].setAngularVelocity(update.limbs[name].av);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/Assert"
|
||||
],
|
||||
|
|
@ -20,12 +20,11 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
Assert.number(this.options.width, this.options.height);
|
||||
Assert.number(this.options.weight);
|
||||
|
||||
var deckShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var w = this.options.width / Settings.RATIO;
|
||||
var h = 2 / Settings.RATIO;
|
||||
deckShape.SetAsOrientedBox(w / 2, h / 2, new Box2D.Common.Math.b2Vec2(0, -(4.5 / Settings.RATIO)));
|
||||
var deckShape = planck.Box(w / 2, h / 2, planck.Vec2(0, -(4.5 / Settings.RATIO)));
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fixtureDef.shape = deckShape;
|
||||
|
||||
var offset = 4,
|
||||
|
|
@ -36,7 +35,7 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
fixtureDef.restitution = 0.2;
|
||||
fixtureDef.isSensor = false;
|
||||
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
this.body.createFixture(fixtureDef);
|
||||
|
||||
|
||||
this.addWheel(
|
||||
|
|
@ -54,18 +53,16 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
Skateboard.prototype.addWheel = function(x, y) {
|
||||
Assert.number(x, y);
|
||||
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
bodyDef.position.x = x / Settings.RATIO;
|
||||
bodyDef.position.y = y / Settings.RATIO;
|
||||
bodyDef.angle = 0;
|
||||
var bodyDef = {
|
||||
type: 'dynamic',
|
||||
position: planck.Vec2(x / Settings.RATIO, y / Settings.RATIO),
|
||||
angle: 0
|
||||
};
|
||||
|
||||
var wheelShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
wheelShape.SetRadius(2.5 / Settings.RATIO);
|
||||
wheelShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(x / Settings.RATIO, y / Settings.RATIO));
|
||||
var wheelShape = planck.Circle(2.5 / Settings.RATIO, planck.Vec2(x / Settings.RATIO, y / Settings.RATIO));
|
||||
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
var offset = 4,
|
||||
factor = 80;
|
||||
var density = ((0.1 + offset) / 3 / 3) * factor;
|
||||
|
|
@ -75,7 +72,7 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
fixtureDef.isSensor = false;
|
||||
fixtureDef.friction = 0.0005;
|
||||
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
this.body.createFixture(fixtureDef);
|
||||
};
|
||||
|
||||
Skateboard.prototype.flip = function(direction) {
|
||||
|
|
@ -90,7 +87,7 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
/*
|
||||
define([
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/Assert"
|
||||
],
|
||||
|
|
@ -121,12 +118,11 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
Assert.number(this.options.width, this.options.height);
|
||||
Assert.number(this.options.weight);
|
||||
|
||||
var deckShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
var w = this.options.width / Settings.RATIO;
|
||||
var h = 1.5 / Settings.RATIO;
|
||||
deckShape.SetAsOrientedBox(w / 2, h / 2, new Box2D.Common.Math.b2Vec2(0, -(4.5 / Settings.RATIO)));
|
||||
var deckShape = planck.Box(w / 2, h / 2, planck.Vec2(0, -(4.5 / Settings.RATIO)));
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
fixtureDef.shape = deckShape;
|
||||
|
||||
var offset = 4,
|
||||
|
|
@ -137,23 +133,21 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
fixtureDef.restitution = Settings.ITEM_RESTITUTION;
|
||||
fixtureDef.isSensor = false;
|
||||
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
this.body.createFixture(fixtureDef);
|
||||
};
|
||||
|
||||
Skateboard.prototype.addWheel = function(x, y) {
|
||||
Assert.number(x, y);
|
||||
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
bodyDef.position.x = x / Settings.RATIO;
|
||||
bodyDef.position.y = y / Settings.RATIO;
|
||||
bodyDef.angle = 0;
|
||||
var bodyDef = {
|
||||
type: 'dynamic',
|
||||
position: planck.Vec2(x / Settings.RATIO, y / Settings.RATIO),
|
||||
angle: 0
|
||||
};
|
||||
|
||||
var wheelShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
wheelShape.SetRadius(1.5 / Settings.RATIO);
|
||||
wheelShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0, 0));
|
||||
var wheelShape = planck.Circle(1.5 / Settings.RATIO, planck.Vec2(0, 0));
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
var fixtureDef = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false };
|
||||
var offset = 4,
|
||||
factor = 80;
|
||||
var density = ((0.1 + offset) / 3 / 3) * factor;
|
||||
|
|
@ -163,7 +157,7 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
fixtureDef.friction = 0;
|
||||
|
||||
var wheelBody = this.body.GetWorld().CreateBody(bodyDef);
|
||||
wheelBody.CreateFixture(fixtureDef);
|
||||
wheelBody.createFixture(fixtureDef);
|
||||
|
||||
//var revoluteJointDef = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
|
||||
var revoluteJointDef = new Box2D.Dynamics.Joints.b2WeldJointDef();
|
||||
|
|
@ -171,7 +165,7 @@ function (Parent, Box2D, Settings, Assert) {
|
|||
|
||||
|
||||
|
||||
revoluteJointDef.Initialize(this.body, wheelBody, wheelBody.GetWorldCenter());
|
||||
revoluteJointDef.Initialize(this.body, wheelBody, wheelBody.getWorldCenter());
|
||||
var j = this.body.GetWorld().CreateJoint(revoluteJointDef);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/" + GLOBALS.context + "/GameObjects/GameObject",
|
||||
"Lib/Vendor/Box2D"
|
||||
"Lib/Vendor/Planck"
|
||||
],
|
||||
|
||||
function (Parent, Box2D) {
|
||||
|
|
@ -14,8 +14,8 @@ function (Parent, Box2D) {
|
|||
SpectatorDoll.prototype = Object.create(Parent.prototype);
|
||||
|
||||
SpectatorDoll.prototype.getBodyDef = function() {
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
var bodyDef = { type: 'static', position: planck.Vec2(0, 0), angle: 0 };
|
||||
bodyDef.type = 'dynamic';
|
||||
bodyDef.position.x = this.getPosition().x;
|
||||
bodyDef.position.y = this.getPosition().y;
|
||||
bodyDef.angle = 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/Config/Settings",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Lib/Utilities/Abstract",
|
||||
"Game/" + GLOBALS.context + "/Collision/Detector",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ define([
|
|||
"Game/" + GLOBALS.context + "/Loader/Level",
|
||||
"Game/Config/Settings",
|
||||
"Game/Config/ItemSettings",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Lib/Utilities/OptionsHelper",
|
||||
"Lib/Utilities/Exception",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ function (Settings, planck, CollisionDetector, nc) {
|
|||
Engine.prototype.setCollisionDetector = function () {
|
||||
|
||||
var detector = new CollisionDetector();
|
||||
this.world.on('begin-contact', detector.getListener());
|
||||
detector.setupWorldEvents(this.world);
|
||||
}
|
||||
|
||||
Engine.prototype.getWorldForRubeLoader = function() {
|
||||
|
|
|
|||
338
app/Lib/Vendor/Box2D.js
vendored
338
app/Lib/Vendor/Box2D.js
vendored
|
|
@ -1413,7 +1413,7 @@ Box2D.postDefs = [];
|
|||
};
|
||||
b2DistanceProxy.b2DistanceProxy = function () {};
|
||||
b2DistanceProxy.prototype.Set = function (shape) {
|
||||
switch (shape.GetType()) {
|
||||
switch (shape.getType()) {
|
||||
case b2Shape.e_circleShape:
|
||||
{
|
||||
var circle = (shape instanceof b2CircleShape ? shape : null);
|
||||
|
|
@ -4447,7 +4447,7 @@ Box2D.postDefs = [];
|
|||
var def = new b2FixtureDef();
|
||||
def.shape = shape;
|
||||
def.density = density;
|
||||
return this.CreateFixture(def);
|
||||
return this.createFixture(def);
|
||||
}
|
||||
b2Body.prototype.DestroyFixture = function (fixture) {
|
||||
if (this.m_world.IsLocked() == true) {
|
||||
|
|
@ -4556,7 +4556,7 @@ Box2D.postDefs = [];
|
|||
}
|
||||
b2Body.prototype.GetDefinition = function () {
|
||||
var bd = new b2BodyDef();
|
||||
bd.type = this.GetType();
|
||||
bd.type = this.getType();
|
||||
bd.allowSleep = (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag;
|
||||
bd.angle = this.GetAngle();
|
||||
bd.angularDamping = this.m_angularDamping;
|
||||
|
|
@ -4574,8 +4574,8 @@ Box2D.postDefs = [];
|
|||
if (this.m_type != b2Body.b2_dynamicBody) {
|
||||
return;
|
||||
}
|
||||
if (this.IsAwake() == false) {
|
||||
this.SetAwake(true);
|
||||
if (this.isAwake() == false) {
|
||||
this.setAwake(true);
|
||||
}
|
||||
this.m_force.x += force.x;
|
||||
this.m_force.y += force.y;
|
||||
|
|
@ -4586,8 +4586,8 @@ Box2D.postDefs = [];
|
|||
if (this.m_type != b2Body.b2_dynamicBody) {
|
||||
return;
|
||||
}
|
||||
if (this.IsAwake() == false) {
|
||||
this.SetAwake(true);
|
||||
if (this.isAwake() == false) {
|
||||
this.setAwake(true);
|
||||
}
|
||||
this.m_torque += torque;
|
||||
}
|
||||
|
|
@ -4595,17 +4595,17 @@ Box2D.postDefs = [];
|
|||
if (this.m_type != b2Body.b2_dynamicBody) {
|
||||
return;
|
||||
}
|
||||
if (this.IsAwake() == false) {
|
||||
this.SetAwake(true);
|
||||
if (this.isAwake() == false) {
|
||||
this.setAwake(true);
|
||||
}
|
||||
this.m_linearVelocity.x += this.m_invMass * impulse.x;
|
||||
this.m_linearVelocity.y += this.m_invMass * impulse.y;
|
||||
this.m_angularVelocity += this.m_invI * ((point.x - this.m_sweep.c.x) * impulse.y - (point.y - this.m_sweep.c.y) * impulse.x);
|
||||
}
|
||||
b2Body.prototype.Split = function (callback) {
|
||||
var linearVelocity = this.GetLinearVelocity().Copy();
|
||||
var angularVelocity = this.GetAngularVelocity();
|
||||
var center = this.GetWorldCenter();
|
||||
var linearVelocity = this.GetLinearVelocity().clone();
|
||||
var angularVelocity = this.getAngularVelocity();
|
||||
var center = this.getWorldCenter();
|
||||
var body1 = this;
|
||||
var body2 = this.m_world.CreateBody(this.GetDefinition());
|
||||
var prev;
|
||||
|
|
@ -4632,14 +4632,14 @@ Box2D.postDefs = [];
|
|||
}
|
||||
body1.ResetMassData();
|
||||
body2.ResetMassData();
|
||||
var center1 = body1.GetWorldCenter();
|
||||
var center2 = body2.GetWorldCenter();
|
||||
var center1 = body1.getWorldCenter();
|
||||
var center2 = body2.getWorldCenter();
|
||||
var velocity1 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center1, center)));
|
||||
var velocity2 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center2, center)));
|
||||
body1.SetLinearVelocity(velocity1);
|
||||
body2.SetLinearVelocity(velocity2);
|
||||
body1.SetAngularVelocity(angularVelocity);
|
||||
body2.SetAngularVelocity(angularVelocity);
|
||||
body1.setAngularVelocity(angularVelocity);
|
||||
body2.setAngularVelocity(angularVelocity);
|
||||
body1.SynchronizeFixtures();
|
||||
body2.SynchronizeFixtures();
|
||||
return body2;
|
||||
|
|
@ -4660,12 +4660,12 @@ Box2D.postDefs = [];
|
|||
var body1 = this;
|
||||
|
||||
var body2 = other;
|
||||
var center1 = body1.GetWorldCenter();
|
||||
var center2 = body2.GetWorldCenter();
|
||||
var velocity1 = body1.GetLinearVelocity().Copy();
|
||||
var velocity2 = body2.GetLinearVelocity().Copy();
|
||||
var angular1 = body1.GetAngularVelocity();
|
||||
var angular = body2.GetAngularVelocity();
|
||||
var center1 = body1.getWorldCenter();
|
||||
var center2 = body2.getWorldCenter();
|
||||
var velocity1 = body1.GetLinearVelocity().clone();
|
||||
var velocity2 = body2.GetLinearVelocity().clone();
|
||||
var angular1 = body1.getAngularVelocity();
|
||||
var angular = body2.getAngularVelocity();
|
||||
body1.ResetMassData();
|
||||
this.SynchronizeFixtures();
|
||||
}
|
||||
|
|
@ -4700,7 +4700,7 @@ Box2D.postDefs = [];
|
|||
this.m_I = massData.I - this.m_mass * (massData.center.x * massData.center.x + massData.center.y * massData.center.y);
|
||||
this.m_invI = 1.0 / this.m_I;
|
||||
}
|
||||
var oldCenter = this.m_sweep.c.Copy();
|
||||
var oldCenter = this.m_sweep.c.clone();
|
||||
this.m_sweep.localCenter.SetV(massData.center);
|
||||
this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter));
|
||||
this.m_sweep.c.SetV(this.m_sweep.c0);
|
||||
|
|
@ -4746,7 +4746,7 @@ Box2D.postDefs = [];
|
|||
this.m_I = 0.0;
|
||||
this.m_invI = 0.0;
|
||||
}
|
||||
var oldCenter = this.m_sweep.c.Copy();
|
||||
var oldCenter = this.m_sweep.c.clone();
|
||||
this.m_sweep.localCenter.SetV(center);
|
||||
this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter));
|
||||
this.m_sweep.c.SetV(this.m_sweep.c0);
|
||||
|
|
@ -4804,7 +4804,7 @@ Box2D.postDefs = [];
|
|||
this.m_linearVelocity.SetZero();
|
||||
this.m_angularVelocity = 0.0;
|
||||
}
|
||||
this.SetAwake(true);
|
||||
this.setAwake(true);
|
||||
this.m_force.SetZero();
|
||||
this.m_torque = 0.0;
|
||||
for (var ce = this.m_contactList; ce; ce = ce.next) {
|
||||
|
|
@ -4831,7 +4831,7 @@ Box2D.postDefs = [];
|
|||
}
|
||||
else {
|
||||
this.m_flags &= ~b2Body.e_allowSleepFlag;
|
||||
this.SetAwake(true);
|
||||
this.setAwake(true);
|
||||
}
|
||||
}
|
||||
b2Body.prototype.SetAwake = function (flag) {
|
||||
|
|
@ -5029,9 +5029,9 @@ Box2D.postDefs = [];
|
|||
Box2D.Dynamics.b2Body.e_bulletFlag = 0x0008;
|
||||
Box2D.Dynamics.b2Body.e_fixedRotationFlag = 0x0010;
|
||||
Box2D.Dynamics.b2Body.e_activeFlag = 0x0020;
|
||||
Box2D.Dynamics.b2Body.b2_staticBody = 0;
|
||||
Box2D.Dynamics.b2Body.b2_kinematicBody = 1;
|
||||
Box2D.Dynamics.b2Body.b2_dynamicBody = 2;
|
||||
'static' = 0;
|
||||
'kinematic' = 1;
|
||||
'dynamic' = 2;
|
||||
});
|
||||
b2BodyDef.b2BodyDef = function () {
|
||||
this.position = new b2Vec2();
|
||||
|
|
@ -5191,7 +5191,7 @@ Box2D.postDefs = [];
|
|||
var fixtureB = c.GetFixtureB();
|
||||
var bodyA = fixtureA.GetBody();
|
||||
var bodyB = fixtureB.GetBody();
|
||||
if (bodyA.IsAwake() == false && bodyB.IsAwake() == false) {
|
||||
if (bodyA.isAwake() == false && bodyB.isAwake() == false) {
|
||||
c = c.GetNext();
|
||||
continue;
|
||||
}
|
||||
|
|
@ -5301,7 +5301,7 @@ Box2D.postDefs = [];
|
|||
this.m_filter = new b2FilterData();
|
||||
};
|
||||
b2Fixture.prototype.GetType = function () {
|
||||
return this.m_shape.GetType();
|
||||
return this.m_shape.getType();
|
||||
}
|
||||
b2Fixture.prototype.GetShape = function () {
|
||||
return this.m_shape;
|
||||
|
|
@ -5323,7 +5323,7 @@ Box2D.postDefs = [];
|
|||
return this.m_isSensor;
|
||||
}
|
||||
b2Fixture.prototype.SetFilterData = function (filter) {
|
||||
this.m_filter = filter.Copy();
|
||||
this.m_filter = filter.clone();
|
||||
if (this.m_body) return;
|
||||
var edge = this.m_body.GetContactList();
|
||||
while (edge) {
|
||||
|
|
@ -5335,7 +5335,7 @@ Box2D.postDefs = [];
|
|||
}
|
||||
}
|
||||
b2Fixture.prototype.GetFilterData = function () {
|
||||
return this.m_filter.Copy();
|
||||
return this.m_filter.clone();
|
||||
}
|
||||
b2Fixture.prototype.GetBody = function () {
|
||||
return this.m_body;
|
||||
|
|
@ -5403,9 +5403,9 @@ Box2D.postDefs = [];
|
|||
this.m_restitution = def.restitution;
|
||||
this.m_body = body;
|
||||
this.m_next = null;
|
||||
this.m_filter = def.filter.Copy();
|
||||
this.m_filter = def.filter.clone();
|
||||
this.m_isSensor = def.isSensor;
|
||||
this.m_shape = def.shape.Copy();
|
||||
this.m_shape = def.shape.clone();
|
||||
this.m_density = def.density;
|
||||
}
|
||||
b2Fixture.prototype.Destroy = function () {
|
||||
|
|
@ -5489,7 +5489,7 @@ Box2D.postDefs = [];
|
|||
for (i = 0;
|
||||
i < this.m_bodyCount; ++i) {
|
||||
b = this.m_bodies[i];
|
||||
if (b.GetType() != b2Body.b2_dynamicBody) continue;
|
||||
if (b.getType() != b2Body.b2_dynamicBody) continue;
|
||||
b.m_linearVelocity.x += step.dt * (gravity.x + b.m_invMass * b.m_force.x);
|
||||
b.m_linearVelocity.y += step.dt * (gravity.y + b.m_invMass * b.m_force.y);
|
||||
b.m_angularVelocity += step.dt * b.m_invI * b.m_torque;
|
||||
|
|
@ -5522,7 +5522,7 @@ Box2D.postDefs = [];
|
|||
for (i = 0;
|
||||
i < this.m_bodyCount; ++i) {
|
||||
b = this.m_bodies[i];
|
||||
if (b.GetType() == b2Body.b2_staticBody) continue;
|
||||
if (b.getType() == b2Body.b2_staticBody) continue;
|
||||
var translationX = step.dt * b.m_linearVelocity.x;
|
||||
var translationY = step.dt * b.m_linearVelocity.y;
|
||||
if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) {
|
||||
|
|
@ -5568,7 +5568,7 @@ Box2D.postDefs = [];
|
|||
for (i = 0;
|
||||
i < this.m_bodyCount; ++i) {
|
||||
b = this.m_bodies[i];
|
||||
if (b.GetType() == b2Body.b2_staticBody) {
|
||||
if (b.getType() == b2Body.b2_staticBody) {
|
||||
continue;
|
||||
}
|
||||
if ((b.m_flags & b2Body.e_allowSleepFlag) == 0) {
|
||||
|
|
@ -5588,7 +5588,7 @@ Box2D.postDefs = [];
|
|||
for (i = 0;
|
||||
i < this.m_bodyCount; ++i) {
|
||||
b = this.m_bodies[i];
|
||||
b.SetAwake(false);
|
||||
b.setAwake(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5613,7 +5613,7 @@ Box2D.postDefs = [];
|
|||
for (i = 0;
|
||||
i < this.m_bodyCount; ++i) {
|
||||
var b = this.m_bodies[i];
|
||||
if (b.GetType() == b2Body.b2_staticBody) continue;
|
||||
if (b.getType() == b2Body.b2_staticBody) continue;
|
||||
var translationX = subStep.dt * b.m_linearVelocity.x;
|
||||
var translationY = subStep.dt * b.m_linearVelocity.y;
|
||||
if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) {
|
||||
|
|
@ -5850,8 +5850,8 @@ Box2D.postDefs = [];
|
|||
}
|
||||
var bodyA = j.m_bodyA;
|
||||
var bodyB = j.m_bodyB;
|
||||
bodyA.SetAwake(true);
|
||||
bodyB.SetAwake(true);
|
||||
bodyA.setAwake(true);
|
||||
bodyB.setAwake(true);
|
||||
if (j.m_edgeA.prev) {
|
||||
j.m_edgeA.prev.next = j.m_edgeA.next;
|
||||
}
|
||||
|
|
@ -6015,15 +6015,15 @@ Box2D.postDefs = [];
|
|||
color.Set(0.5, 0.5, 0.3);
|
||||
this.DrawShape(s, xf, color);
|
||||
}
|
||||
else if (b.GetType() == b2Body.b2_staticBody) {
|
||||
else if (b.getType() == b2Body.b2_staticBody) {
|
||||
color.Set(0.5, 0.9, 0.5);
|
||||
this.DrawShape(s, xf, color);
|
||||
}
|
||||
else if (b.GetType() == b2Body.b2_kinematicBody) {
|
||||
else if (b.getType() == b2Body.b2_kinematicBody) {
|
||||
color.Set(0.5, 0.5, 0.9);
|
||||
this.DrawShape(s, xf, color);
|
||||
}
|
||||
else if (b.IsAwake() == false) {
|
||||
else if (b.isAwake() == false) {
|
||||
color.Set(0.6, 0.6, 0.6);
|
||||
this.DrawShape(s, xf, color);
|
||||
}
|
||||
|
|
@ -6079,7 +6079,7 @@ Box2D.postDefs = [];
|
|||
b; b = b.m_next) {
|
||||
xf = b2World.s_xf;
|
||||
xf.R = b.m_xf.R;
|
||||
xf.position = b.GetWorldCenter();
|
||||
xf.position = b.getWorldCenter();
|
||||
this.m_debugDraw.DrawTransform(xf);
|
||||
}
|
||||
}
|
||||
|
|
@ -6203,10 +6203,10 @@ Box2D.postDefs = [];
|
|||
if (seed.m_flags & b2Body.e_islandFlag) {
|
||||
continue;
|
||||
}
|
||||
if (seed.IsAwake() == false || seed.IsActive() == false) {
|
||||
if (seed.isAwake() == false || seed.IsActive() == false) {
|
||||
continue;
|
||||
}
|
||||
if (seed.GetType() == b2Body.b2_staticBody) {
|
||||
if (seed.getType() == b2Body.b2_staticBody) {
|
||||
continue;
|
||||
}
|
||||
island.Clear();
|
||||
|
|
@ -6216,10 +6216,10 @@ Box2D.postDefs = [];
|
|||
while (stackCount > 0) {
|
||||
b = stack[--stackCount];
|
||||
island.AddBody(b);
|
||||
if (b.IsAwake() == false) {
|
||||
b.SetAwake(true);
|
||||
if (b.isAwake() == false) {
|
||||
b.setAwake(true);
|
||||
}
|
||||
if (b.GetType() == b2Body.b2_staticBody) {
|
||||
if (b.getType() == b2Body.b2_staticBody) {
|
||||
continue;
|
||||
}
|
||||
var other;
|
||||
|
|
@ -6259,7 +6259,7 @@ Box2D.postDefs = [];
|
|||
island.Solve(step, this.m_gravity, this.m_allowSleep);
|
||||
for (var i = 0; i < island.m_bodyCount; ++i) {
|
||||
b = island.m_bodies[i];
|
||||
if (b.GetType() == b2Body.b2_staticBody) {
|
||||
if (b.getType() == b2Body.b2_staticBody) {
|
||||
b.m_flags &= ~b2Body.e_islandFlag;
|
||||
}
|
||||
}
|
||||
|
|
@ -6271,10 +6271,10 @@ Box2D.postDefs = [];
|
|||
}
|
||||
for (b = this.m_bodyList;
|
||||
b; b = b.m_next) {
|
||||
if (b.IsAwake() == false || b.IsActive() == false) {
|
||||
if (b.isAwake() == false || b.IsActive() == false) {
|
||||
continue;
|
||||
}
|
||||
if (b.GetType() == b2Body.b2_staticBody) {
|
||||
if (b.getType() == b2Body.b2_staticBody) {
|
||||
continue;
|
||||
}
|
||||
b.SynchronizeFixtures();
|
||||
|
|
@ -6323,7 +6323,7 @@ Box2D.postDefs = [];
|
|||
fB = c.m_fixtureB;
|
||||
bA = fA.m_body;
|
||||
bB = fB.m_body;
|
||||
if ((bA.GetType() != b2Body.b2_dynamicBody || bA.IsAwake() == false) && (bB.GetType() != b2Body.b2_dynamicBody || bB.IsAwake() == false)) {
|
||||
if ((bA.getType() != b2Body.b2_dynamicBody || bA.isAwake() == false) && (bB.getType() != b2Body.b2_dynamicBody || bB.isAwake() == false)) {
|
||||
continue;
|
||||
}
|
||||
var t0 = bA.m_sweep.t0;
|
||||
|
|
@ -6373,7 +6373,7 @@ Box2D.postDefs = [];
|
|||
continue;
|
||||
}
|
||||
var seed = bA;
|
||||
if (seed.GetType() != b2Body.b2_dynamicBody) {
|
||||
if (seed.getType() != b2Body.b2_dynamicBody) {
|
||||
seed = bB;
|
||||
}
|
||||
island.Clear();
|
||||
|
|
@ -6385,10 +6385,10 @@ Box2D.postDefs = [];
|
|||
b = queue[queueStart++];
|
||||
--queueSize;
|
||||
island.AddBody(b);
|
||||
if (b.IsAwake() == false) {
|
||||
b.SetAwake(true);
|
||||
if (b.isAwake() == false) {
|
||||
b.setAwake(true);
|
||||
}
|
||||
if (b.GetType() != b2Body.b2_dynamicBody) {
|
||||
if (b.getType() != b2Body.b2_dynamicBody) {
|
||||
continue;
|
||||
}
|
||||
for (cEdge = b.m_contactList;
|
||||
|
|
@ -6408,9 +6408,9 @@ Box2D.postDefs = [];
|
|||
if (other.m_flags & b2Body.e_islandFlag) {
|
||||
continue;
|
||||
}
|
||||
if (other.GetType() != b2Body.b2_staticBody) {
|
||||
if (other.getType() != b2Body.b2_staticBody) {
|
||||
other.Advance(minTOI);
|
||||
other.SetAwake(true);
|
||||
other.setAwake(true);
|
||||
}
|
||||
queue[queueStart + queueSize] = other;
|
||||
++queueSize;
|
||||
|
|
@ -6426,9 +6426,9 @@ Box2D.postDefs = [];
|
|||
island.AddJoint(jEdge.joint);
|
||||
jEdge.joint.m_islandFlag = true;
|
||||
if (other.m_flags & b2Body.e_islandFlag) continue;
|
||||
if (other.GetType() != b2Body.b2_staticBody) {
|
||||
if (other.getType() != b2Body.b2_staticBody) {
|
||||
other.Advance(minTOI);
|
||||
other.SetAwake(true);
|
||||
other.setAwake(true);
|
||||
}
|
||||
queue[queueStart + queueSize] = other;
|
||||
++queueSize;
|
||||
|
|
@ -6448,10 +6448,10 @@ Box2D.postDefs = [];
|
|||
i < island.m_bodyCount; ++i) {
|
||||
b = island.m_bodies[i];
|
||||
b.m_flags &= ~b2Body.e_islandFlag;
|
||||
if (b.IsAwake() == false) {
|
||||
if (b.isAwake() == false) {
|
||||
continue;
|
||||
}
|
||||
if (b.GetType() != b2Body.b2_dynamicBody) {
|
||||
if (b.getType() != b2Body.b2_dynamicBody) {
|
||||
continue;
|
||||
}
|
||||
b.SynchronizeFixtures();
|
||||
|
|
@ -6716,7 +6716,7 @@ Box2D.postDefs = [];
|
|||
}
|
||||
var bodyA = fixtureA.GetBody();
|
||||
var bodyB = fixtureB.GetBody();
|
||||
if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) {
|
||||
if (bodyA.getType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.getType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) {
|
||||
this.m_flags |= b2Contact.e_continuousFlag;
|
||||
}
|
||||
this.m_fixtureA = fixtureA;
|
||||
|
|
@ -6754,7 +6754,7 @@ Box2D.postDefs = [];
|
|||
this.m_manifold.m_pointCount = 0;
|
||||
}
|
||||
else {
|
||||
if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) {
|
||||
if (bodyA.getType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.getType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) {
|
||||
this.m_flags |= b2Contact.e_continuousFlag;
|
||||
}
|
||||
else {
|
||||
|
|
@ -6782,8 +6782,8 @@ Box2D.postDefs = [];
|
|||
this.m_manifold.m_pointCount = 0;
|
||||
}
|
||||
if (touching != wasTouching) {
|
||||
bodyA.SetAwake(true);
|
||||
bodyB.SetAwake(true);
|
||||
bodyA.setAwake(true);
|
||||
bodyB.setAwake(true);
|
||||
}
|
||||
}
|
||||
if (touching) {
|
||||
|
|
@ -6872,8 +6872,8 @@ Box2D.postDefs = [];
|
|||
this.AddType(b2PolyAndEdgeContact.Create, b2PolyAndEdgeContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_edgeShape);
|
||||
}
|
||||
b2ContactFactory.prototype.Create = function (fixtureA, fixtureB) {
|
||||
var type1 = parseInt(fixtureA.GetType());
|
||||
var type2 = parseInt(fixtureB.GetType());
|
||||
var type1 = parseInt(fixtureA.getType());
|
||||
var type2 = parseInt(fixtureB.getType());
|
||||
var reg = this.m_registers[type1][type2];
|
||||
var c;
|
||||
if (reg.pool) {
|
||||
|
|
@ -6902,11 +6902,11 @@ Box2D.postDefs = [];
|
|||
}
|
||||
b2ContactFactory.prototype.Destroy = function (contact) {
|
||||
if (contact.m_manifold.m_pointCount > 0) {
|
||||
contact.m_fixtureA.m_body.SetAwake(true);
|
||||
contact.m_fixtureB.m_body.SetAwake(true);
|
||||
contact.m_fixtureA.m_body.setAwake(true);
|
||||
contact.m_fixtureB.m_body.setAwake(true);
|
||||
}
|
||||
var type1 = parseInt(contact.m_fixtureA.GetType());
|
||||
var type2 = parseInt(contact.m_fixtureB.GetType());
|
||||
var type1 = parseInt(contact.m_fixtureA.getType());
|
||||
var type2 = parseInt(contact.m_fixtureB.getType());
|
||||
var reg = this.m_registers[type1][type2];
|
||||
if (true) {
|
||||
reg.poolCount++;
|
||||
|
|
@ -7367,8 +7367,8 @@ Box2D.postDefs = [];
|
|||
b2PolyAndCircleContact.Destroy = function (contact, allocator) {}
|
||||
b2PolyAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) {
|
||||
this.__super.Reset.call(this, fixtureA, fixtureB);
|
||||
b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape);
|
||||
b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_circleShape);
|
||||
b2Settings.b2Assert(fixtureA.getType() == b2Shape.e_polygonShape);
|
||||
b2Settings.b2Assert(fixtureB.getType() == b2Shape.e_circleShape);
|
||||
}
|
||||
b2PolyAndCircleContact.prototype.Evaluate = function () {
|
||||
var bA = this.m_fixtureA.m_body;
|
||||
|
|
@ -7386,8 +7386,8 @@ Box2D.postDefs = [];
|
|||
b2PolyAndEdgeContact.Destroy = function (contact, allocator) {}
|
||||
b2PolyAndEdgeContact.prototype.Reset = function (fixtureA, fixtureB) {
|
||||
this.__super.Reset.call(this, fixtureA, fixtureB);
|
||||
b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape);
|
||||
b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_edgeShape);
|
||||
b2Settings.b2Assert(fixtureA.getType() == b2Shape.e_polygonShape);
|
||||
b2Settings.b2Assert(fixtureB.getType() == b2Shape.e_edgeShape);
|
||||
}
|
||||
b2PolyAndEdgeContact.prototype.Evaluate = function () {
|
||||
var bA = this.m_fixtureA.GetBody();
|
||||
|
|
@ -7566,11 +7566,11 @@ Box2D.postDefs = [];
|
|||
b2BuoyancyController.prototype.Step = function (step) {
|
||||
if (!this.m_bodyList) return;
|
||||
if (this.useWorldGravity) {
|
||||
this.gravity = this.GetWorld().GetGravity().Copy();
|
||||
this.gravity = this.GetWorld().GetGravity().clone();
|
||||
}
|
||||
for (var i = this.m_bodyList; i; i = i.nextBody) {
|
||||
var body = i.body;
|
||||
if (body.IsAwake() == false) {
|
||||
if (body.isAwake() == false) {
|
||||
continue;
|
||||
}
|
||||
var areac = new b2Vec2();
|
||||
|
|
@ -7601,12 +7601,12 @@ Box2D.postDefs = [];
|
|||
if (area < Number.MIN_VALUE) continue;
|
||||
var buoyancyForce = this.gravity.GetNegative();
|
||||
buoyancyForce.Multiply(this.density * area);
|
||||
body.ApplyForce(buoyancyForce, massc);
|
||||
body.applyForce(buoyancyForce, massc);
|
||||
var dragForce = body.GetLinearVelocityFromWorldPoint(areac);
|
||||
dragForce.Subtract(this.velocity);
|
||||
dragForce.Multiply((-this.linearDrag * area));
|
||||
body.ApplyForce(dragForce, areac);
|
||||
body.ApplyTorque((-body.GetInertia() / body.GetMass() * area * body.GetAngularVelocity() * this.angularDrag));
|
||||
body.applyForce(dragForce, areac);
|
||||
body.applyTorque((-body.getInertia() / body.getMass() * area * body.getAngularVelocity() * this.angularDrag));
|
||||
}
|
||||
}
|
||||
b2BuoyancyController.prototype.Draw = function (debugDraw) {
|
||||
|
|
@ -7630,7 +7630,7 @@ Box2D.postDefs = [];
|
|||
var smallA = new b2Vec2(this.A.x * step.dt, this.A.y * step.dt);
|
||||
for (var i = this.m_bodyList; i; i = i.nextBody) {
|
||||
var body = i.body;
|
||||
if (!body.IsAwake()) continue;
|
||||
if (!body.isAwake()) continue;
|
||||
body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + smallA.x, body.GetLinearVelocity().y + smallA.y));
|
||||
}
|
||||
}
|
||||
|
|
@ -7643,8 +7643,8 @@ Box2D.postDefs = [];
|
|||
b2ConstantForceController.prototype.Step = function (step) {
|
||||
for (var i = this.m_bodyList; i; i = i.nextBody) {
|
||||
var body = i.body;
|
||||
if (!body.IsAwake()) continue;
|
||||
body.ApplyForce(this.F, body.GetWorldCenter());
|
||||
if (!body.isAwake()) continue;
|
||||
body.applyForce(this.F, body.getWorldCenter());
|
||||
}
|
||||
}
|
||||
b2Controller.b2Controller = function () {};
|
||||
|
|
@ -7715,21 +7715,21 @@ Box2D.postDefs = [];
|
|||
for (i = this.m_bodyList;
|
||||
i; i = i.nextBody) {
|
||||
body1 = i.body;
|
||||
p1 = body1.GetWorldCenter();
|
||||
mass1 = body1.GetMass();
|
||||
p1 = body1.getWorldCenter();
|
||||
mass1 = body1.getMass();
|
||||
for (j = this.m_bodyList;
|
||||
j != i; j = j.nextBody) {
|
||||
body2 = j.body;
|
||||
p2 = body2.GetWorldCenter();
|
||||
p2 = body2.getWorldCenter();
|
||||
dx = p2.x - p1.x;
|
||||
dy = p2.y - p1.y;
|
||||
r2 = dx * dx + dy * dy;
|
||||
if (r2 < Number.MIN_VALUE) continue;
|
||||
f = new b2Vec2(dx, dy);
|
||||
f.Multiply(this.G / r2 / Math.sqrt(r2) * mass1 * body2.GetMass());
|
||||
if (body1.IsAwake()) body1.ApplyForce(f, p1);
|
||||
f.Multiply(this.G / r2 / Math.sqrt(r2) * mass1 * body2.getMass());
|
||||
if (body1.isAwake()) body1.applyForce(f, p1);
|
||||
f.Multiply((-1));
|
||||
if (body2.IsAwake()) body2.ApplyForce(f, p2);
|
||||
if (body2.isAwake()) body2.applyForce(f, p2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7737,21 +7737,21 @@ Box2D.postDefs = [];
|
|||
for (i = this.m_bodyList;
|
||||
i; i = i.nextBody) {
|
||||
body1 = i.body;
|
||||
p1 = body1.GetWorldCenter();
|
||||
mass1 = body1.GetMass();
|
||||
p1 = body1.getWorldCenter();
|
||||
mass1 = body1.getMass();
|
||||
for (j = this.m_bodyList;
|
||||
j != i; j = j.nextBody) {
|
||||
body2 = j.body;
|
||||
p2 = body2.GetWorldCenter();
|
||||
p2 = body2.getWorldCenter();
|
||||
dx = p2.x - p1.x;
|
||||
dy = p2.y - p1.y;
|
||||
r2 = dx * dx + dy * dy;
|
||||
if (r2 < Number.MIN_VALUE) continue;
|
||||
f = new b2Vec2(dx, dy);
|
||||
f.Multiply(this.G / r2 * mass1 * body2.GetMass());
|
||||
if (body1.IsAwake()) body1.ApplyForce(f, p1);
|
||||
f.Multiply(this.G / r2 * mass1 * body2.getMass());
|
||||
if (body1.isAwake()) body1.applyForce(f, p1);
|
||||
f.Multiply((-1));
|
||||
if (body2.IsAwake()) body2.ApplyForce(f, p2);
|
||||
if (body2.isAwake()) body2.applyForce(f, p2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7783,7 +7783,7 @@ Box2D.postDefs = [];
|
|||
if (timestep > this.maxTimestep && this.maxTimestep > 0) timestep = this.maxTimestep;
|
||||
for (var i = this.m_bodyList; i; i = i.nextBody) {
|
||||
var body = i.body;
|
||||
if (!body.IsAwake()) {
|
||||
if (!body.isAwake()) {
|
||||
continue;
|
||||
}
|
||||
var damping = body.GetWorldVector(b2Math.MulMV(this.T, body.GetLocalVector(body.GetLinearVelocity())));
|
||||
|
|
@ -7848,10 +7848,10 @@ Box2D.postDefs = [];
|
|||
this.m_u = new b2Vec2();
|
||||
};
|
||||
b2DistanceJoint.prototype.GetAnchorA = function () {
|
||||
return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
|
||||
return this.m_bodyA.getWorldPoint(this.m_localAnchor1);
|
||||
}
|
||||
b2DistanceJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchor2);
|
||||
}
|
||||
b2DistanceJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -8042,8 +8042,8 @@ Box2D.postDefs = [];
|
|||
b2DistanceJointDef.prototype.Initialize = function (bA, bB, anchorA, anchorB) {
|
||||
this.bodyA = bA;
|
||||
this.bodyB = bB;
|
||||
this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchorA));
|
||||
this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchorB));
|
||||
this.localAnchorA.SetV(this.bodyA.getLocalPoint(anchorA));
|
||||
this.localAnchorB.SetV(this.bodyB.getLocalPoint(anchorB));
|
||||
var dX = anchorB.x - anchorA.x;
|
||||
var dY = anchorB.y - anchorA.y;
|
||||
this.length = Math.sqrt(dX * dX + dY * dY);
|
||||
|
|
@ -8060,10 +8060,10 @@ Box2D.postDefs = [];
|
|||
this.m_linearImpulse = new b2Vec2();
|
||||
};
|
||||
b2FrictionJoint.prototype.GetAnchorA = function () {
|
||||
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA);
|
||||
return this.m_bodyA.getWorldPoint(this.m_localAnchorA);
|
||||
}
|
||||
b2FrictionJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchorB);
|
||||
}
|
||||
b2FrictionJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -8192,7 +8192,7 @@ Box2D.postDefs = [];
|
|||
var CdotX = vB.x - wB * rBY - vA.x + wA * rAY;
|
||||
var CdotY = vB.y + wB * rBX - vA.y - wA * rAX;
|
||||
var impulseV = b2Math.MulMV(this.m_linearMass, new b2Vec2((-CdotX), (-CdotY)));
|
||||
var oldImpulseV = this.m_linearImpulse.Copy();
|
||||
var oldImpulseV = this.m_linearImpulse.clone();
|
||||
this.m_linearImpulse.Add(impulseV);
|
||||
maxImpulse = step.dt * this.m_maxForce;
|
||||
if (this.m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) {
|
||||
|
|
@ -8230,8 +8230,8 @@ Box2D.postDefs = [];
|
|||
b2FrictionJointDef.prototype.Initialize = function (bA, bB, anchor) {
|
||||
this.bodyA = bA;
|
||||
this.bodyB = bB;
|
||||
this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor));
|
||||
this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor));
|
||||
this.localAnchorA.SetV(this.bodyA.getLocalPoint(anchor));
|
||||
this.localAnchorB.SetV(this.bodyB.getLocalPoint(anchor));
|
||||
}
|
||||
Box2D.inherit(b2GearJoint, Box2D.Dynamics.Joints.b2Joint);
|
||||
b2GearJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
|
||||
|
|
@ -8244,10 +8244,10 @@ Box2D.postDefs = [];
|
|||
this.m_J = new b2Jacobian();
|
||||
};
|
||||
b2GearJoint.prototype.GetAnchorA = function () {
|
||||
return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
|
||||
return this.m_bodyA.getWorldPoint(this.m_localAnchor1);
|
||||
}
|
||||
b2GearJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchor2);
|
||||
}
|
||||
b2GearJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -8613,10 +8613,10 @@ Box2D.postDefs = [];
|
|||
this.m_impulse = new b2Vec2();
|
||||
};
|
||||
b2LineJoint.prototype.GetAnchorA = function () {
|
||||
return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
|
||||
return this.m_bodyA.getWorldPoint(this.m_localAnchor1);
|
||||
}
|
||||
b2LineJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchor2);
|
||||
}
|
||||
b2LineJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -8630,8 +8630,8 @@ Box2D.postDefs = [];
|
|||
var bA = this.m_bodyA;
|
||||
var bB = this.m_bodyB;
|
||||
var tMat;
|
||||
var p1 = bA.GetWorldPoint(this.m_localAnchor1);
|
||||
var p2 = bB.GetWorldPoint(this.m_localAnchor2);
|
||||
var p1 = bA.getWorldPoint(this.m_localAnchor1);
|
||||
var p2 = bB.getWorldPoint(this.m_localAnchor2);
|
||||
var dX = p2.x - p1.x;
|
||||
var dY = p2.y - p1.y;
|
||||
var axis = bA.GetWorldVector(this.m_localXAxis1);
|
||||
|
|
@ -8672,8 +8672,8 @@ Box2D.postDefs = [];
|
|||
return this.m_enableLimit;
|
||||
}
|
||||
b2LineJoint.prototype.EnableLimit = function (flag) {
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_enableLimit = flag;
|
||||
}
|
||||
b2LineJoint.prototype.GetLowerLimit = function () {
|
||||
|
|
@ -8685,8 +8685,8 @@ Box2D.postDefs = [];
|
|||
b2LineJoint.prototype.SetLimits = function (lower, upper) {
|
||||
if (lower === undefined) lower = 0;
|
||||
if (upper === undefined) upper = 0;
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_lowerTranslation = lower;
|
||||
this.m_upperTranslation = upper;
|
||||
}
|
||||
|
|
@ -8694,14 +8694,14 @@ Box2D.postDefs = [];
|
|||
return this.m_enableMotor;
|
||||
}
|
||||
b2LineJoint.prototype.EnableMotor = function (flag) {
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_enableMotor = flag;
|
||||
}
|
||||
b2LineJoint.prototype.SetMotorSpeed = function (speed) {
|
||||
if (speed === undefined) speed = 0;
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_motorSpeed = speed;
|
||||
}
|
||||
b2LineJoint.prototype.GetMotorSpeed = function () {
|
||||
|
|
@ -8709,8 +8709,8 @@ Box2D.postDefs = [];
|
|||
}
|
||||
b2LineJoint.prototype.SetMaxMotorForce = function (force) {
|
||||
if (force === undefined) force = 0;
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_maxMotorForce = force;
|
||||
}
|
||||
b2LineJoint.prototype.GetMaxMotorForce = function () {
|
||||
|
|
@ -8867,7 +8867,7 @@ Box2D.postDefs = [];
|
|||
var Cdot1 = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1;
|
||||
if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) {
|
||||
var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1;
|
||||
var f1 = this.m_impulse.Copy();
|
||||
var f1 = this.m_impulse.clone();
|
||||
var df = this.m_K.Solve(new b2Vec2(), (-Cdot1), (-Cdot2));
|
||||
this.m_impulse.Add(df);
|
||||
if (this.m_limitState == b2Joint.e_atLowerLimit) {
|
||||
|
|
@ -9053,8 +9053,8 @@ Box2D.postDefs = [];
|
|||
b2LineJointDef.prototype.Initialize = function (bA, bB, anchor, axis) {
|
||||
this.bodyA = bA;
|
||||
this.bodyB = bB;
|
||||
this.localAnchorA = this.bodyA.GetLocalPoint(anchor);
|
||||
this.localAnchorB = this.bodyB.GetLocalPoint(anchor);
|
||||
this.localAnchorA = this.bodyA.getLocalPoint(anchor);
|
||||
this.localAnchorB = this.bodyB.getLocalPoint(anchor);
|
||||
this.localAxisA = this.bodyA.GetLocalVector(axis);
|
||||
}
|
||||
Box2D.inherit(b2MouseJoint, Box2D.Dynamics.Joints.b2Joint);
|
||||
|
|
@ -9074,7 +9074,7 @@ Box2D.postDefs = [];
|
|||
return this.m_target;
|
||||
}
|
||||
b2MouseJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchor);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchor);
|
||||
}
|
||||
b2MouseJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -9088,8 +9088,8 @@ Box2D.postDefs = [];
|
|||
return this.m_target;
|
||||
}
|
||||
b2MouseJoint.prototype.SetTarget = function (target) {
|
||||
if (this.m_bodyB.IsAwake() == false) {
|
||||
this.m_bodyB.SetAwake(true);
|
||||
if (this.m_bodyB.isAwake() == false) {
|
||||
this.m_bodyB.setAwake(true);
|
||||
}
|
||||
this.m_target = target;
|
||||
}
|
||||
|
|
@ -9131,7 +9131,7 @@ Box2D.postDefs = [];
|
|||
}
|
||||
b2MouseJoint.prototype.InitVelocityConstraints = function (step) {
|
||||
var b = this.m_bodyB;
|
||||
var mass = b.GetMass();
|
||||
var mass = b.getMass();
|
||||
var omega = 2.0 * Math.PI * this.m_frequencyHz;
|
||||
var d = 2.0 * mass * this.m_dampingRatio * omega;
|
||||
var k = mass * omega * omega;
|
||||
|
|
@ -9229,10 +9229,10 @@ Box2D.postDefs = [];
|
|||
this.m_impulse = new b2Vec3();
|
||||
};
|
||||
b2PrismaticJoint.prototype.GetAnchorA = function () {
|
||||
return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
|
||||
return this.m_bodyA.getWorldPoint(this.m_localAnchor1);
|
||||
}
|
||||
b2PrismaticJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchor2);
|
||||
}
|
||||
b2PrismaticJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -9246,8 +9246,8 @@ Box2D.postDefs = [];
|
|||
var bA = this.m_bodyA;
|
||||
var bB = this.m_bodyB;
|
||||
var tMat;
|
||||
var p1 = bA.GetWorldPoint(this.m_localAnchor1);
|
||||
var p2 = bB.GetWorldPoint(this.m_localAnchor2);
|
||||
var p1 = bA.getWorldPoint(this.m_localAnchor1);
|
||||
var p2 = bB.getWorldPoint(this.m_localAnchor2);
|
||||
var dX = p2.x - p1.x;
|
||||
var dY = p2.y - p1.y;
|
||||
var axis = bA.GetWorldVector(this.m_localXAxis1);
|
||||
|
|
@ -9288,8 +9288,8 @@ Box2D.postDefs = [];
|
|||
return this.m_enableLimit;
|
||||
}
|
||||
b2PrismaticJoint.prototype.EnableLimit = function (flag) {
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_enableLimit = flag;
|
||||
}
|
||||
b2PrismaticJoint.prototype.GetLowerLimit = function () {
|
||||
|
|
@ -9301,8 +9301,8 @@ Box2D.postDefs = [];
|
|||
b2PrismaticJoint.prototype.SetLimits = function (lower, upper) {
|
||||
if (lower === undefined) lower = 0;
|
||||
if (upper === undefined) upper = 0;
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_lowerTranslation = lower;
|
||||
this.m_upperTranslation = upper;
|
||||
}
|
||||
|
|
@ -9310,14 +9310,14 @@ Box2D.postDefs = [];
|
|||
return this.m_enableMotor;
|
||||
}
|
||||
b2PrismaticJoint.prototype.EnableMotor = function (flag) {
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_enableMotor = flag;
|
||||
}
|
||||
b2PrismaticJoint.prototype.SetMotorSpeed = function (speed) {
|
||||
if (speed === undefined) speed = 0;
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_motorSpeed = speed;
|
||||
}
|
||||
b2PrismaticJoint.prototype.GetMotorSpeed = function () {
|
||||
|
|
@ -9325,8 +9325,8 @@ Box2D.postDefs = [];
|
|||
}
|
||||
b2PrismaticJoint.prototype.SetMaxMotorForce = function (force) {
|
||||
if (force === undefined) force = 0;
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_maxMotorForce = force;
|
||||
}
|
||||
b2PrismaticJoint.prototype.GetMotorForce = function () {
|
||||
|
|
@ -9487,7 +9487,7 @@ Box2D.postDefs = [];
|
|||
var Cdot1Y = w2 - w1;
|
||||
if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) {
|
||||
var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1;
|
||||
var f1 = this.m_impulse.Copy();
|
||||
var f1 = this.m_impulse.clone();
|
||||
var df = this.m_K.Solve33(new b2Vec3(), (-Cdot1X), (-Cdot1Y), (-Cdot2));
|
||||
this.m_impulse.Add(df);
|
||||
if (this.m_limitState == b2Joint.e_atLowerLimit) {
|
||||
|
|
@ -9672,8 +9672,8 @@ Box2D.postDefs = [];
|
|||
b2PrismaticJointDef.prototype.Initialize = function (bA, bB, anchor, axis) {
|
||||
this.bodyA = bA;
|
||||
this.bodyB = bB;
|
||||
this.localAnchorA = this.bodyA.GetLocalPoint(anchor);
|
||||
this.localAnchorB = this.bodyB.GetLocalPoint(anchor);
|
||||
this.localAnchorA = this.bodyA.getLocalPoint(anchor);
|
||||
this.localAnchorB = this.bodyB.getLocalPoint(anchor);
|
||||
this.localAxisA = this.bodyA.GetLocalVector(axis);
|
||||
this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle();
|
||||
}
|
||||
|
|
@ -9689,10 +9689,10 @@ Box2D.postDefs = [];
|
|||
this.m_u2 = new b2Vec2();
|
||||
};
|
||||
b2PulleyJoint.prototype.GetAnchorA = function () {
|
||||
return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
|
||||
return this.m_bodyA.getWorldPoint(this.m_localAnchor1);
|
||||
}
|
||||
b2PulleyJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchor2);
|
||||
}
|
||||
b2PulleyJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -9703,17 +9703,17 @@ Box2D.postDefs = [];
|
|||
return 0.0;
|
||||
}
|
||||
b2PulleyJoint.prototype.GetGroundAnchorA = function () {
|
||||
var a = this.m_ground.m_xf.position.Copy();
|
||||
var a = this.m_ground.m_xf.position.clone();
|
||||
a.Add(this.m_groundAnchor1);
|
||||
return a;
|
||||
}
|
||||
b2PulleyJoint.prototype.GetGroundAnchorB = function () {
|
||||
var a = this.m_ground.m_xf.position.Copy();
|
||||
var a = this.m_ground.m_xf.position.clone();
|
||||
a.Add(this.m_groundAnchor2);
|
||||
return a;
|
||||
}
|
||||
b2PulleyJoint.prototype.GetLength1 = function () {
|
||||
var p = this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
|
||||
var p = this.m_bodyA.getWorldPoint(this.m_localAnchor1);
|
||||
var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x;
|
||||
var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y;
|
||||
var dX = p.x - sX;
|
||||
|
|
@ -9721,7 +9721,7 @@ Box2D.postDefs = [];
|
|||
return Math.sqrt(dX * dX + dY * dY);
|
||||
}
|
||||
b2PulleyJoint.prototype.GetLength2 = function () {
|
||||
var p = this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
|
||||
var p = this.m_bodyB.getWorldPoint(this.m_localAnchor2);
|
||||
var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x;
|
||||
var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y;
|
||||
var dX = p.x - sX;
|
||||
|
|
@ -10086,8 +10086,8 @@ Box2D.postDefs = [];
|
|||
this.bodyB = bB;
|
||||
this.groundAnchorA.SetV(gaA);
|
||||
this.groundAnchorB.SetV(gaB);
|
||||
this.localAnchorA = this.bodyA.GetLocalPoint(anchorA);
|
||||
this.localAnchorB = this.bodyB.GetLocalPoint(anchorB);
|
||||
this.localAnchorA = this.bodyA.getLocalPoint(anchorA);
|
||||
this.localAnchorB = this.bodyB.getLocalPoint(anchorB);
|
||||
var d1X = anchorA.x - gaA.x;
|
||||
var d1Y = anchorA.y - gaA.y;
|
||||
this.lengthA = Math.sqrt(d1X * d1X + d1Y * d1Y);
|
||||
|
|
@ -10116,10 +10116,10 @@ Box2D.postDefs = [];
|
|||
this.m_mass = new b2Mat33();
|
||||
};
|
||||
b2RevoluteJoint.prototype.GetAnchorA = function () {
|
||||
return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
|
||||
return this.m_bodyA.getWorldPoint(this.m_localAnchor1);
|
||||
}
|
||||
b2RevoluteJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchor2);
|
||||
}
|
||||
b2RevoluteJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -10155,8 +10155,8 @@ Box2D.postDefs = [];
|
|||
this.m_upperAngle = upper;
|
||||
}
|
||||
b2RevoluteJoint.prototype.IsMotorEnabled = function () {
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
return this.m_enableMotor;
|
||||
}
|
||||
b2RevoluteJoint.prototype.EnableMotor = function (flag) {
|
||||
|
|
@ -10164,8 +10164,8 @@ Box2D.postDefs = [];
|
|||
}
|
||||
b2RevoluteJoint.prototype.SetMotorSpeed = function (speed) {
|
||||
if (speed === undefined) speed = 0;
|
||||
this.m_bodyA.SetAwake(true);
|
||||
this.m_bodyB.SetAwake(true);
|
||||
this.m_bodyA.setAwake(true);
|
||||
this.m_bodyB.setAwake(true);
|
||||
this.m_motorSpeed = speed;
|
||||
}
|
||||
b2RevoluteJoint.prototype.GetMotorSpeed = function () {
|
||||
|
|
@ -10509,8 +10509,8 @@ Box2D.postDefs = [];
|
|||
b2RevoluteJointDef.prototype.Initialize = function (bA, bB, anchor) {
|
||||
this.bodyA = bA;
|
||||
this.bodyB = bB;
|
||||
this.localAnchorA = this.bodyA.GetLocalPoint(anchor);
|
||||
this.localAnchorB = this.bodyB.GetLocalPoint(anchor);
|
||||
this.localAnchorA = this.bodyA.getLocalPoint(anchor);
|
||||
this.localAnchorB = this.bodyB.getLocalPoint(anchor);
|
||||
this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle();
|
||||
}
|
||||
Box2D.inherit(b2WeldJoint, Box2D.Dynamics.Joints.b2Joint);
|
||||
|
|
@ -10523,10 +10523,10 @@ Box2D.postDefs = [];
|
|||
this.m_mass = new b2Mat33();
|
||||
};
|
||||
b2WeldJoint.prototype.GetAnchorA = function () {
|
||||
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA);
|
||||
return this.m_bodyA.getWorldPoint(this.m_localAnchorA);
|
||||
}
|
||||
b2WeldJoint.prototype.GetAnchorB = function () {
|
||||
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB);
|
||||
return this.m_bodyB.getWorldPoint(this.m_localAnchorB);
|
||||
}
|
||||
b2WeldJoint.prototype.GetReactionForce = function (inv_dt) {
|
||||
if (inv_dt === undefined) inv_dt = 0;
|
||||
|
|
@ -10697,8 +10697,8 @@ Box2D.postDefs = [];
|
|||
b2WeldJointDef.prototype.Initialize = function (bA, bB, anchor) {
|
||||
this.bodyA = bA;
|
||||
this.bodyB = bB;
|
||||
this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor));
|
||||
this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor));
|
||||
this.localAnchorA.SetV(this.bodyA.getLocalPoint(anchor));
|
||||
this.localAnchorB.SetV(this.bodyB.getLocalPoint(anchor));
|
||||
this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle();
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
6
app/Lib/Vendor/Rube/loadrube.js
vendored
6
app/Lib/Vendor/Rube/loadrube.js
vendored
|
|
@ -68,7 +68,7 @@ function loadFixtureFromRUBE(body, fixtureJso) {
|
|||
fd.shape.m_radius = fixtureJso.circle.radius;
|
||||
if ( fixtureJso.circle.center )
|
||||
fd.shape.m_p.SetV(fixtureJso.circle.center);
|
||||
var fixture = body.CreateFixture(fd);
|
||||
var fixture = body.createFixture(fd);
|
||||
if ( fixtureJso.name )
|
||||
fixture.name = fixtureJso.name;
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ function loadFixtureFromRUBE(body, fixtureJso) {
|
|||
for (v = 0; v < fixtureJso.polygon.vertices.x.length; v++)
|
||||
verts.push( new b2Vec2( fixtureJso.polygon.vertices.x[v], fixtureJso.polygon.vertices.y[v] ) );
|
||||
fd.shape.SetAsArray(verts, verts.length);
|
||||
var fixture = body.CreateFixture(fd);
|
||||
var fixture = body.createFixture(fd);
|
||||
if ( fixture && fixtureJso.name )
|
||||
fixture.name = fixtureJso.name;
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ function loadFixtureFromRUBE(body, fixtureJso) {
|
|||
var thisVertex = new b2Vec2( fixtureJso.chain.vertices.x[v], fixtureJso.chain.vertices.y[v] );
|
||||
if ( v > 0 ) {
|
||||
fd.shape.SetAsEdge( lastVertex, thisVertex );
|
||||
var fixture = body.CreateFixture(fd);
|
||||
var fixture = body.createFixture(fd);
|
||||
if ( fixtureJso.name )
|
||||
fixture.name = fixtureJso.name;
|
||||
}
|
||||
|
|
|
|||
10
app/Lib/Vendor/RubeLoader.js
vendored
10
app/Lib/Vendor/RubeLoader.js
vendored
|
|
@ -1,5 +1,5 @@
|
|||
define([
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
@ -72,7 +72,7 @@ function (Box2D) {
|
|||
ClipVertex = Box2D.Collision.ClipVertex,
|
||||
Features = Box2D.Collision.Features,
|
||||
IBroadPhase = Box2D.Collision.IBroadPhase;
|
||||
b2_dynamicBody = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
b2_dynamicBody = 'dynamic';
|
||||
b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge,
|
||||
IBroadPhase = Box2D.Collision.IBroadPhase,
|
||||
b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact,
|
||||
|
|
@ -194,7 +194,7 @@ function (Box2D) {
|
|||
fd.shape.m_radius = fixtureJson.circle.radius;
|
||||
if ( fixtureJson.circle.center )
|
||||
fd.shape.m_p.SetV(fixtureJson.circle.center);
|
||||
var fixture = body.CreateFixture(fd);
|
||||
var fixture = body.createFixture(fd);
|
||||
if ( fixtureJson.name )
|
||||
fixture.name = fixtureJson.name;
|
||||
}
|
||||
|
|
@ -206,7 +206,7 @@ function (Box2D) {
|
|||
for (v = fixtureJson.polygon.vertices.x.length - 1; v >= 0 ; v--)
|
||||
verts.push( new b2Vec2( fixtureJson.polygon.vertices.x[v], -fixtureJson.polygon.vertices.y[v] ) );
|
||||
fd.shape.SetAsArray(verts, verts.length);
|
||||
var fixture = body.CreateFixture(fd);
|
||||
var fixture = body.createFixture(fd);
|
||||
if ( fixture && fixtureJson.name )
|
||||
fixture.name = fixtureJson.name;
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ function (Box2D) {
|
|||
var thisVertex = new b2Vec2( fixtureJson.chain.vertices.x[v], -fixtureJson.chain.vertices.y[v] );
|
||||
if ( v < fixtureJson.chain.vertices.x.length - 1 ) {
|
||||
fd.shape.SetAsEdge( lastVertex, thisVertex );
|
||||
var fixture = body.CreateFixture(fd);
|
||||
var fixture = body.createFixture(fd);
|
||||
if ( fixtureJson.name )
|
||||
fixture.name = fixtureJson.name;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue