|
@@ -7403,40 +7403,40 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
|
|
|
- // if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
|
|
|
- this._cachedVertexBuffers = vertexBuffers;
|
|
|
- this._cachedEffectForVertexBuffers = effect;
|
|
|
- var attributes = effect.getAttributesNames();
|
|
|
- for (var index = 0; index < attributes.length; index++) {
|
|
|
- var order = effect.getAttributeLocation(index);
|
|
|
- if (order >= 0) {
|
|
|
- var vertexBuffer = vertexBuffers[attributes[index]];
|
|
|
- if (!vertexBuffer) {
|
|
|
- if (this._vertexAttribArraysEnabled[order]) {
|
|
|
- this._gl.disableVertexAttribArray(order);
|
|
|
- this._vertexAttribArraysEnabled[order] = false;
|
|
|
+ if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
|
|
|
+ this._cachedVertexBuffers = vertexBuffers;
|
|
|
+ this._cachedEffectForVertexBuffers = effect;
|
|
|
+ var attributes = effect.getAttributesNames();
|
|
|
+ for (var index = 0; index < attributes.length; index++) {
|
|
|
+ var order = effect.getAttributeLocation(index);
|
|
|
+ if (order >= 0) {
|
|
|
+ var vertexBuffer = vertexBuffers[attributes[index]];
|
|
|
+ if (!vertexBuffer) {
|
|
|
+ if (this._vertexAttribArraysEnabled[order]) {
|
|
|
+ this._gl.disableVertexAttribArray(order);
|
|
|
+ this._vertexAttribArraysEnabled[order] = false;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!this._vertexAttribArraysEnabled[order]) {
|
|
|
+ this._gl.enableVertexAttribArray(order);
|
|
|
+ this._vertexAttribArraysEnabled[order] = true;
|
|
|
+ }
|
|
|
+ var buffer = vertexBuffer.getBuffer();
|
|
|
+ this.vertexAttribPointer(buffer, order, vertexBuffer.getSize(), this._gl.FLOAT, false, vertexBuffer.getStrideSize() * 4, vertexBuffer.getOffset() * 4);
|
|
|
+ if (vertexBuffer.getIsInstanced()) {
|
|
|
+ this._caps.instancedArrays.vertexAttribDivisorANGLE(order, 1);
|
|
|
+ this._currentInstanceLocations.push(order);
|
|
|
+ this._currentInstanceBuffers.push(buffer);
|
|
|
}
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!this._vertexAttribArraysEnabled[order]) {
|
|
|
- this._gl.enableVertexAttribArray(order);
|
|
|
- this._vertexAttribArraysEnabled[order] = true;
|
|
|
- }
|
|
|
- var buffer = vertexBuffer.getBuffer();
|
|
|
- this.vertexAttribPointer(buffer, order, vertexBuffer.getSize(), this._gl.FLOAT, false, vertexBuffer.getStrideSize() * 4, vertexBuffer.getOffset() * 4);
|
|
|
- if (vertexBuffer.getIsInstanced()) {
|
|
|
- this._caps.instancedArrays.vertexAttribDivisorANGLE(order, 1);
|
|
|
- this._currentInstanceLocations.push(order);
|
|
|
- this._currentInstanceBuffers.push(buffer);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // }
|
|
|
- // if (indexBuffer != null && this._cachedIndexBuffer !== indexBuffer) {
|
|
|
- this._cachedIndexBuffer = indexBuffer;
|
|
|
- this.bindIndexBuffer(indexBuffer);
|
|
|
- this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
|
|
|
- //}
|
|
|
+ if (indexBuffer != null && this._cachedIndexBuffer !== indexBuffer) {
|
|
|
+ this._cachedIndexBuffer = indexBuffer;
|
|
|
+ this.bindIndexBuffer(indexBuffer);
|
|
|
+ this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
|
|
|
+ }
|
|
|
};
|
|
|
Engine.prototype.unbindInstanceAttributes = function () {
|
|
|
var boundBuffer;
|
|
@@ -47426,6 +47426,9 @@ var BABYLON;
|
|
|
configurable: true
|
|
|
});
|
|
|
SolidParticle.prototype.intersectsMesh = function (target) {
|
|
|
+ if (!(this.isVisible && target.isVisible)) {
|
|
|
+ return false; // only visible particle and target can intersect
|
|
|
+ }
|
|
|
if (!this._boundingInfo || !target._boundingInfo) {
|
|
|
return false;
|
|
|
}
|
|
@@ -47586,6 +47589,7 @@ var BABYLON;
|
|
|
vertexData.applyToMesh(mesh, this._updatable);
|
|
|
this.mesh = mesh;
|
|
|
this.mesh.isPickable = this._pickable;
|
|
|
+ this._wm = this.mesh.getWorldMatrix();
|
|
|
// free memory
|
|
|
this._positions = null;
|
|
|
this._normals = null;
|
|
@@ -47670,10 +47674,14 @@ var BABYLON;
|
|
|
for (v = 0; v < shape.length; v++) {
|
|
|
shape[v].subtractInPlace(barycenter);
|
|
|
}
|
|
|
+ var bInfo;
|
|
|
+ if (this._particlesIntersect) {
|
|
|
+ bInfo = new BABYLON.BoundingInfo(barycenter, barycenter);
|
|
|
+ }
|
|
|
var modelShape = new BABYLON.ModelShape(this._shapeCounter, shape, shapeUV, null, null);
|
|
|
// add the particle in the SPS
|
|
|
this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
|
|
|
- this._addParticle(idx, this._positions.length, modelShape, this._shapeCounter, 0);
|
|
|
+ this._addParticle(idx, this._positions.length, modelShape, this._shapeCounter, 0, bInfo);
|
|
|
// initialize the particle position
|
|
|
this.particles[this.nbParticles].position.addInPlace(barycenter);
|
|
|
this._index += shape.length;
|
|
@@ -47792,8 +47800,8 @@ var BABYLON;
|
|
|
return shapeUV;
|
|
|
};
|
|
|
// adds a new particle object in the particles array
|
|
|
- SolidParticleSystem.prototype._addParticle = function (idx, idxpos, model, shapeId, idxInShape, bbInfo) {
|
|
|
- this.particles.push(new BABYLON.SolidParticle(idx, idxpos, model, shapeId, idxInShape, bbInfo));
|
|
|
+ SolidParticleSystem.prototype._addParticle = function (idx, idxpos, model, shapeId, idxInShape, bInfo) {
|
|
|
+ this.particles.push(new BABYLON.SolidParticle(idx, idxpos, model, shapeId, idxInShape, bInfo));
|
|
|
};
|
|
|
/**
|
|
|
* Adds some particles to the SPS from the model shape. Returns the shape id.
|
|
@@ -47913,7 +47921,7 @@ var BABYLON;
|
|
|
// if the particles will always face the camera
|
|
|
if (this.billboard) {
|
|
|
// compute the camera position and un-rotate it by the current mesh rotation
|
|
|
- if (this.mesh._worldMatrix.decompose(this._scale, this._quaternion, this._translation)) {
|
|
|
+ if (this._wm.decompose(this._scale, this._quaternion, this._translation)) {
|
|
|
this._quaternionToRotationMatrix();
|
|
|
this._rotMatrix.invertToRef(this._invertMatrix);
|
|
|
this._camera._currentTarget.subtractToRef(this._camera.globalPosition, this._camDir);
|
|
@@ -48099,8 +48107,8 @@ var BABYLON;
|
|
|
bSphere.radius = 0.0;
|
|
|
}
|
|
|
// then update the bbox and the bsphere into the world system
|
|
|
- bBox._update(this.mesh.getWorldMatrix());
|
|
|
- bSphere._update(this.mesh.getWorldMatrix());
|
|
|
+ bBox._update(this._wm);
|
|
|
+ bSphere._update(this._wm);
|
|
|
}
|
|
|
// increment indexes for the next particle
|
|
|
index = idx + 3;
|