More room plane updates

This commit is contained in:
Bill 2023-01-14 00:23:14 -05:00
parent f5d617f092
commit 17bc510b4f
8 changed files with 10 additions and 144 deletions

View File

@ -247,13 +247,6 @@ export class RoomPlane implements IRoomPlane
public dispose(): void
{
if(this._bitmapData)
{
this._bitmapData.destroy(true);
this._bitmapData = null;
}
this._activeTexture = null;
this._location = null;
this._origin = null;
@ -801,7 +794,7 @@ export class RoomPlane implements IRoomPlane
this._maskBitmapData = null;
}
this._maskBitmapData = this._textureCache.createAndFillRenderTexture(width, height);
this._maskBitmapData = this._textureCache.createAndFillRenderTexture(width, height, 'mask');
this._maskChanged = true;
}

View File

@ -7,14 +7,12 @@ import { AnimationItem } from './AnimationItem';
export class PlaneVisualizationAnimationLayer implements IDisposable
{
private _color: number = 0;
private _bitmapData: RenderTexture = null;
private _isDisposed: boolean = false;
private _items: AnimationItem[];
constructor(k: any, assets: IGraphicAssetCollection)
{
this._color = 0;
this._bitmapData = null;
this._isDisposed = false;
this._items = [];
@ -45,13 +43,6 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
{
this._isDisposed = true;
if(this._bitmapData)
{
this._bitmapData.destroy();
this._bitmapData = null;
}
if(this._items)
{
for(const item of this._items) item && item.dispose();
@ -62,32 +53,10 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
public clearCache(): void
{
if(this._bitmapData)
{
this._bitmapData.destroy(true);
this._bitmapData = null;
}
}
public render(textureCache: PlaneTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, offsetX: number, offsetY: number, maxX: number, maxY: number, dimensionX: number, dimensionY: number, timeSinceStartMs: number): RenderTexture
{
/* if(!canvas || (canvas.width !== width) || (canvas.height !== height))
{
if(!this._bitmapData || (this._bitmapData.width !== width) || (this._bitmapData.height !== height))
{
if(this._bitmapData) this._bitmapData.destroy(true);
this._bitmapData = textureCache.createRenderTexture(width, height);
}
else
{
textureCache.clearRenderTexture(this._bitmapData);
}
canvas = this._bitmapData;
} */
if(((maxX > 0) && (maxY > 0)))
{
let index = 0;

View File

@ -7,7 +7,6 @@ import { PlaneTexture } from './PlaneTexture';
export class PlaneMaterialCell
{
private _cachedSprite: Sprite;
private _texture: PlaneTexture;
private _extraItemOffsets: Point[];
private _extraItemAssets: IGraphicAsset[];
@ -15,7 +14,6 @@ export class PlaneMaterialCell
constructor(texture: PlaneTexture, assets: IGraphicAsset[] = null, offsetPoints: Point[] = null, limit: number = 0)
{
this._cachedSprite = null;
this._texture = texture;
this._extraItemOffsets = [];
this._extraItemAssets = [];
@ -69,13 +67,6 @@ export class PlaneMaterialCell
this._texture = null;
}
if(this._cachedSprite)
{
this._cachedSprite.destroy();
this._cachedSprite = null;
}
this._extraItemAssets = null;
this._extraItemOffsets = null;
this._extraItemCount = 0;
@ -83,12 +74,6 @@ export class PlaneMaterialCell
public clearCache(): void
{
if(this._cachedSprite)
{
this._cachedSprite.destroy();
this._cachedSprite = null;
}
}
public getHeight(normal: IVector3D): number
@ -138,10 +123,6 @@ export class PlaneMaterialCell
if(!this.isStatic)
{
if(this._cachedSprite) this._cachedSprite.destroy();
this._cachedSprite = bitmap;
const limitMin = Math.min(this._extraItemCount, this._extraItemOffsets.length);
const limitMax = Math.max(this._extraItemCount, this._extraItemOffsets.length);
const offsetIndexes = Randomizer.getArray(this._extraItemCount, limitMax);
@ -194,14 +175,12 @@ export class PlaneMaterialCell
sprite.transform.setFromMatrix(flipMatrix);
this._cachedSprite.addChild(sprite);
bitmap.addChild(sprite);
}
}
i++;
}
return this._cachedSprite;
}
return bitmap;

View File

@ -83,12 +83,7 @@ export class PlaneMaterialCellColumn
this._cells = null;
}
if(this._cachedBitmapData)
{
this._cachedBitmapData.destroy(true);
this._cachedBitmapData = null;
}
this._cachedBitmapData = null;
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
}
@ -97,12 +92,7 @@ export class PlaneMaterialCellColumn
{
if(!this._isCached) return;
if(this._cachedBitmapData)
{
this._cachedBitmapData.destroy(true);
this._cachedBitmapData = null;
}
if(this._cachedBitmapData) this._cachedBitmapData = null;
if(this._cachedBitmapNormal)
{

View File

@ -99,13 +99,6 @@ export class PlaneMaterialCellMatrix
public dispose(): void
{
if(this._cachedBitmapData)
{
this._cachedBitmapData.destroy(true);
this._cachedBitmapData = null;
}
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
}
@ -113,13 +106,6 @@ export class PlaneMaterialCellMatrix
{
if(!this._isCached) return;
if(this._cachedBitmapData)
{
this._cachedBitmapData.destroy();
this._cachedBitmapData = null;
}
if(this._cachedBitmapNormal)
{
this._cachedBitmapNormal.x = 0;
@ -168,7 +154,7 @@ export class PlaneMaterialCellMatrix
{
if(this._cachedBitmapData)
{
if((this._cachedBitmapData.width === width) && (this._cachedBitmapData.height === height) && Vector3d.isEqual(this._cachedBitmapNormal, normal))
if(this._cachedBitmapData.baseTexture && (this._cachedBitmapData.width === width) && (this._cachedBitmapData.height === height) && Vector3d.isEqual(this._cachedBitmapNormal, normal))
{
if(canvas)
{

View File

@ -9,7 +9,6 @@ export class PlaneVisualization
{
private _layers: IDisposable[];
private _geometry: IRoomGeometry;
private _cachedBitmapData: RenderTexture;
private _cachedBitmapNormal: Vector3d;
private _isCached: boolean;
private _hasAnimationLayers: boolean;
@ -18,7 +17,6 @@ export class PlaneVisualization
{
this._layers = [];
this._geometry = geometry;
this._cachedBitmapData = null;
this._cachedBitmapNormal = new Vector3d();
this._isCached = false;
this._hasAnimationLayers = false;
@ -61,13 +59,6 @@ export class PlaneVisualization
this._geometry = null;
if(this._cachedBitmapData)
{
this._cachedBitmapData.destroy();
this._cachedBitmapData = null;
}
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
}
@ -75,13 +66,6 @@ export class PlaneVisualization
{
if(!this._isCached) return;
if(this._cachedBitmapData)
{
this._cachedBitmapData.destroy();
this._cachedBitmapData = null;
}
if(this._cachedBitmapNormal)
{
this._cachedBitmapNormal.assign(new Vector3d());
@ -146,31 +130,9 @@ export class PlaneVisualization
if((!canvas || (canvas.width !== width)) || (canvas.height !== height)) canvas = null;
/* if(this._cachedBitmapData)
{
if((this._cachedBitmapData.width === width) && (this._cachedBitmapData.height === height) && (Vector3d.isEqual(this._cachedBitmapNormal, normal)))
{
if(!this.hasAnimationLayers)
{
if(canvas)
{
textureCache.writeToRenderTexture(new Sprite(this._cachedBitmapData), canvas, true);
return canvas;
}
return this._cachedBitmapData;
}
}
else
{
this._cachedBitmapData = null;
}
} */
this._isCached = true;
this._cachedBitmapData = textureCache.createAndFillRenderTexture(width, height, planeId);
const bitmap = textureCache.createAndFillRenderTexture(width, height, planeId);
this._cachedBitmapNormal.assign(normal);
@ -182,16 +144,16 @@ export class PlaneVisualization
if(layer instanceof PlaneVisualizationLayer)
{
layer.render(planeId, textureCache, this._cachedBitmapData, width, height, normal, useTexture, offsetX, offsetY);
layer.render(`${ planeId }:${ this._layers.indexOf(layer) }`, textureCache, bitmap, width, height, normal, useTexture, offsetX, offsetY);
}
else if(layer instanceof PlaneVisualizationAnimationLayer)
{
layer.render(textureCache, this._cachedBitmapData, width, height, normal, offsetX, offsetY, maxX, maxY, dimensionX, dimensionY, timeSinceStartMs);
layer.render(textureCache, bitmap, width, height, normal, offsetX, offsetY, maxX, maxY, dimensionX, dimensionY, timeSinceStartMs);
}
}
}
return this._cachedBitmapData;
return bitmap;
}
}

View File

@ -15,7 +15,6 @@ export class PlaneVisualizationLayer
private _color: number;
private _offset: number;
private _align: number;
private _bitmapData: RenderTexture;
private _isDisposed: boolean;
constructor(material: PlaneMaterial, color: number, align: number, offset: number = 0)
@ -24,7 +23,6 @@ export class PlaneVisualizationLayer
this._offset = offset;
this._align = align;
this._color = color;
this._bitmapData = null;
this._isDisposed = false;
}
@ -53,12 +51,6 @@ export class PlaneVisualizationLayer
public clearCache(): void
{
if(this._bitmapData)
{
this._bitmapData.destroy(true);
this._bitmapData = null;
}
}
public render(planeId: string, textureCache: PlaneTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number): RenderTexture

View File

@ -14,12 +14,7 @@ export class PlaneTextureCache
public clearCache(): void
{
const previousTextures = this.RENDER_TEXTURE_CACHE.slice();
setTimeout(() =>
{
previousTextures.forEach(renderTexture => renderTexture?.destroy(true));
}, 1000);
this.RENDER_TEXTURE_POOL.forEach(renderTexture => renderTexture?.destroy(true));
this.RENDER_TEXTURE_POOL.clear();
this.RENDER_TEXTURE_CACHE = [];