Move matrix + silhouette updates into method

This commit is contained in:
adroitwhiz
2020-05-19 16:02:12 -04:00
parent d73aeb1ac1
commit e7b1504117
5 changed files with 27 additions and 21 deletions

View File

@@ -452,6 +452,8 @@ class Drawable {
/**
* Check if the world position touches the skin.
* The caller is responsible for ensuring this drawable's inverse matrix & its skin's silhouette are up-to-date.
* @see updateCPURenderAttributes
* @param {twgl.v3} vec World coordinate vector.
* @return {boolean} True if the world position touches the skin.
*/
@@ -632,6 +634,15 @@ class Drawable {
}
}
/**
* Update everything necessary to render this drawable on the CPU.
*/
updateCPURenderAttributes () {
this.updateMatrix();
// CPU rendering always occurs at the "native" size, so no need to scale up this._scale
if (this.skin) this.skin.updateSilhouette(this._scale);
}
/**
* Respond to an internal change in the current Skin.
* @private
@@ -676,6 +687,8 @@ class Drawable {
/**
* Sample a color from a drawable's texture.
* The caller is responsible for ensuring this drawable's inverse matrix & its skin's silhouette are up-to-date.
* @see updateCPURenderAttributes
* @param {twgl.v3} vec The scratch space [x,y] vector
* @param {Drawable} drawable The drawable to sample the texture from
* @param {Uint8ClampedArray} dst The "color4b" representation of the texture at point.