Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Transform nodes memoise when super transform updated

#131

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);
};

Reported by lindsay.kay (at xeolabs) · July 27th, 2010 @ 11:31 AM

State: resolved
Milestone: V0.7.7

Activity

  1. lindsay.kay (at xeolabs)
    lindsay.kay (at xeolabs)
    • State changed from new to resolved
    • Milestone set to V0.7.7

    August 3rd, 2010 @ 11:38 PM

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.