Transform nodes memoise when super transform updated
Reported by lindsay.kay (at xeolabs) | July 27th, 2010 @ 11:31 AM | in V0.7.7
Transform nodes are supposed to discard internally memoised state when any super-transform properties have been modified via setter methods.
Description
Problem found where if they start in memoLevel 1 (when statically configured) and are lucky enough to ascend to memoLevel 2, they don't reset to memoLevel 1 when a super node has had an attribute updated (eg. angle, translation, scale etc) because they don't check.
SceneJS.Scale.prototype._render = function(traversalContext, data) {
if (this._memoLevel == 0) {
if (!this._fixedParams) {
this._init(this._getParams(data));
} else {
this._memoLevel = 1;
}
this._mat = SceneJS._math_scalingMat4v([this._x, this._y, this._z]);
}
var superXform = SceneJS._modelViewTransformModule.getTransform();
if (this._memoLevel < 2) {
var instancing = SceneJS._instancingModule.instancing();
var tempMat = SceneJS._math_mulMat4(superXform.matrix, this._mat);
this._xform = {
localMatrix: this._mat,
matrix: tempMat,
fixed: superXform.fixed && this._fixedParams && !instancing
};
////////////////////////
// Calculate memo level
////////////////////////
if (this._memoLevel == 1 && superXform.fixed && !instancing) { // Bump up memoization level if model-space fixed
this._memoLevel = 2;
}
}
SceneJS._modelViewTransformModule.setTransform(this._xform);
this._renderNodes(traversalContext, data);
SceneJS._modelViewTransformModule.setTransform(superXform);
};
Fix
Inherit memoLevels on the matrix stack:
SceneJS.Scale.prototype._render = function(traversalContext, data) {
if (this._memoLevel == 0) {
if (!this._fixedParams) {
this._init(this._getParams(data));
} else {
this._memoLevel = 1;
}
this._mat = SceneJS._math_scalingMat4v([this._x, this._y, this._z]);
}
var superXform = SceneJS._modelViewTransformModule.getTransform();
if (this._memoLevel < 2) {
var instancing = SceneJS._instancingModule.instancing();
//////////////////////////
// calculate memoLevel
//////////////////////////
if (this._memoLevel == 1 && superXform.fixed && !instancing) { // Bump up memoization level if model-space fixed
this._memoLevel = 2;
}
var tempMat = SceneJS._math_mulMat4(superXform.matrix, this._mat);
this._xform = {
localMatrix: this._mat,
matrix: tempMat,
fixed: this._memoLevel == 2 ///// Mark matrix on stack as fixed if at memoLevel 2
};
}
SceneJS._modelViewTransformModule.setTransform(this._xform);
this._renderNodes(traversalContext, data);
SceneJS._modelViewTransformModule.setTransform(superXform);
};
Comments and changes to this ticket
-
lindsay.kay (at xeolabs) August 3rd, 2010 @ 11:38 PM
- State changed from new to resolved
- Milestone set to V0.7.7
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
SceneJS provides easy access to WebGL through a simple and declarative JavaScript API. The SceneJS API is functional, which enables its scene definitions to be really compact and expressive, while hooking into other JavaScript code just that little bit more smoothly.