Skip to content

Commit

Permalink
Fix for false positive on sphere/heightfield bail (legacy schteppe#265)
Browse files Browse the repository at this point in the history
schteppe#265

Additionally, some formatting and typos
  • Loading branch information
stockhuman committed Mar 7, 2020
1 parent 5e3dddf commit 3e6da95
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/world/Narrowphase.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FrictionEquation } from '../equations/FrictionEquation'
* @constructor
* @todo Sphere-ConvexPolyhedron contacts
* @todo Contact reduction
* @todo should move methods to prototype
* @todo should move methods to prototype
*/
export class Narrowphase {
constructor(world) {
Expand Down Expand Up @@ -285,13 +285,9 @@ const tmpQuat2 = new Quaternion()
let numWarnings = 0
const maxWarnings = 10

function warn(msg) {
if (numWarnings > maxWarnings) {
return
}

function warn (msg) {
if (numWarnings > maxWarnings) { return }
numWarnings++

console.warn(msg)
}

Expand Down Expand Up @@ -1189,14 +1185,14 @@ Narrowphase.prototype[
this.createFrictionEquationsFromContact(r, this.frictionResult)

// Release world vertices
for (var j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {
for (let j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {
v3pool.release(faceVerts[j])
}

return // We only expect *one* face contact
} else {
// Edge?
for (var j = 0; j !== face.length; j++) {
for (let j = 0; j !== face.length; j++) {
// Get two world transformed vertices
const v1 = v3pool.get()
const v2 = v3pool.get()
Expand Down Expand Up @@ -1253,7 +1249,7 @@ Narrowphase.prototype[
this.createFrictionEquationsFromContact(r, this.frictionResult)

// Release world vertices
for (var j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {
for (let j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {
v3pool.release(faceVerts[j])
}

Expand All @@ -1275,7 +1271,7 @@ Narrowphase.prototype[
}

// Release world vertices
for (var j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {
for (let j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {
v3pool.release(faceVerts[j])
}
}
Expand Down Expand Up @@ -1958,7 +1954,7 @@ Narrowphase.prototype[
let iMaxY = Math.ceil((localSpherePos.y + radius) / w) + 1

// Bail out if we are out of the terrain
if (iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMaxY > data[0].length) {
if (iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMinY > data[0].length) {
return
}

Expand Down Expand Up @@ -1993,7 +1989,7 @@ Narrowphase.prototype[
const min = minMax[0]
const max = minMax[1]

// Bail out if we're cant touch the bounding height box
// Bail out if we can't touch the bounding height box
if (localSpherePos.z - radius > max || localSpherePos.z + radius < min) {
return
}
Expand Down

0 comments on commit 3e6da95

Please sign in to comment.