Skip to content

Commit

Permalink
renamed MeshDataComponent#autoCompute -> #modelBoundDirty
Browse files Browse the repository at this point in the history
  • Loading branch information
schteppe committed May 18, 2016
1 parent ac4f7fd commit fd62062
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/goo/addons/terrainpack/Forrest.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Forrest.prototype.loadLODTrees = function (world, terrainQuery, forrestAtlasText
meshDataComponent.modelBound.xExtent = this.patchSize;
meshDataComponent.modelBound.yExtent = 500;
meshDataComponent.modelBound.zExtent = this.patchSize;
meshDataComponent.autoCompute = false;
meshDataComponent.modelBoundDirty = false;
entity.set(meshDataComponent);
entity.addToWorld();
this.grid[x][z] = entity;
Expand Down
2 changes: 1 addition & 1 deletion src/goo/addons/terrainpack/Vegetation.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Vegetation.prototype.init = function (world, terrainQuery, vegetationAtlasTextur
meshDataComponent.modelBound.xExtent = this.patchSize;
meshDataComponent.modelBound.yExtent = 500;
meshDataComponent.modelBound.zExtent = this.patchSize;
meshDataComponent.autoCompute = false;
meshDataComponent.modelBoundDirty = false;
entity.set(meshDataComponent);
entity.addToWorld();
this.grid[x][z] = entity;
Expand Down
16 changes: 8 additions & 8 deletions src/goo/entities/components/MeshDataComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ function MeshDataComponent(meshData) {
*/
this.modelBound = new BoundingBox();

/** Automatically compute bounding fit.
/**
* @type {boolean}
* @default
*/
this.autoCompute = true;
this.modelBoundDirty = true;

/**
* @type {SkeletonPose}
Expand All @@ -49,25 +49,25 @@ MeshDataComponent.prototype.constructor = MeshDataComponent;
* Set the bounding volume type (sphere, box etc).
*
* @param {BoundingVolume} modelBound Bounding to apply to this meshdata component.
* @param {boolean} autoCompute If true, automatically compute bounding fit.
* @param {boolean} [setBoundsDirty=true] Whether to set modelBoundDirty=true.
*/
MeshDataComponent.prototype.setModelBound = function (modelBound, autoCompute) {
MeshDataComponent.prototype.setModelBound = function (modelBound, setBoundsDirty) {
this.modelBound = modelBound;
this.autoCompute = autoCompute;
this.modelBoundDirty = setBoundsDirty !== undefined ? setBoundsDirty : true;
};

/**
* Compute bounding center and bounds for this mesh.
*/
MeshDataComponent.prototype.computeBoundFromPoints = function () {
if (!this.autoCompute) {
if (!this.modelBoundDirty) {
return;
}
if (this.modelBound !== null && this.meshData) {
var verts = this.meshData.getAttributeBuffer('POSITION');
if (verts !== undefined) {
this.modelBound.computeFromPoints(verts);
this.autoCompute = false;
this.modelBoundDirty = false;
}
} else {
this.modelBound.reset();
Expand All @@ -93,7 +93,7 @@ MeshDataComponent.prototype.clone = function (options) {
clone.modelBound = this.modelBound.clone();
}

clone.autoCompute = this.autoCompute;
clone.modelBoundDirty = this.modelBoundDirty;

return clone;
};
Expand Down
2 changes: 1 addition & 1 deletion src/goo/entities/systems/BoundingUpdateSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BoundingUpdateSystem.prototype.process = function (entities) {

transformComponent.sync();

if (meshDataComponent.autoCompute) {
if (meshDataComponent.modelBoundDirty) {
meshDataComponent.computeBoundFromPoints();
meshRendererComponent.updateBounds(meshDataComponent.modelBound, transformComponent.worldTransform);
} else if (meshRendererComponent._worldBoundDirty) {
Expand Down
2 changes: 1 addition & 1 deletion src/goo/entities/systems/ParticlesSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ParticlesSystem.prototype.updateParticles = function (particleEntity, particleCo
// tell particle meshdata we are updated.
if (needsUpdate) {
particleComponent.meshData.vertexData._dataNeedsRefresh = true;
particleEntity.meshDataComponent.autoCompute = true;
particleEntity.meshDataComponent.modelBoundDirty = true;
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/goo/loaders/handlers/MeshDataComponentHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ MeshDataComponentHandler.prototype.update = function (entity, config, options) {
var shapeCreator = ShapeCreatorMemoized['create' + StringUtils.capitalize(config.shape)];
if (shapeCreator) {
component.meshData = shapeCreator(config.shapeOptions, component.meshData);
component.autoCompute = true;
component.modelBoundDirty = true;
return component;
}
} else if (config.meshRef) {
Expand Down Expand Up @@ -101,7 +101,7 @@ MeshDataComponentHandler.prototype.update = function (entity, config, options) {
});
} else {
component.meshData = null;
component.autoCompute = true;
component.modelBoundDirty = true;
}
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/goo/quadpack/QuadComponentHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ QuadComponentHandler.prototype.update = function (entity, config, options) {

component.setMaterial(material);
component.rebuildMeshData();
component.meshDataComponent.autoCompute = true;
component.meshDataComponent.modelBoundDirty = true;

return component;
});
Expand Down

0 comments on commit fd62062

Please sign in to comment.