Skip to content
Permalink
Browse files

feat(gameObject): gameObjectAPI add disposeGameObjectRemoveTexture api

  • Loading branch information...
yyc-git committed May 26, 2019
1 parent 27485bc commit 8818438b0195235e6f291233d0e3db273a5b10dc
@@ -280,6 +280,8 @@ let batchDisposeGameObject = GameObjectAPI.batchDisposeGameObject;

let initGameObject = GameObjectAPI.initGameObject;

let disposeGameObjectRemoveTexture = GameObjectAPI.disposeGameObjectRemoveTexture;

let disposeGameObjectDisposeGeometryRemoveMaterial = GameObjectAPI.disposeGameObjectDisposeGeometryRemoveMaterial;

let disposeGameObjectKeepOrderRemoveGeometryRemoveMaterial = GameObjectAPI.disposeGameObjectKeepOrderRemoveGeometryRemoveMaterial;
@@ -1070,6 +1072,8 @@ let batchDisposeGameObject = GameObjectAPI.batchDisposeGameObject;

let initGameObject = GameObjectAPI.initGameObject;

let disposeGameObjectRemoveTexture = GameObjectAPI.disposeGameObjectRemoveTexture;

let disposeGameObjectDisposeGeometryRemoveMaterial = GameObjectAPI.disposeGameObjectDisposeGeometryRemoveMaterial;

let disposeGameObjectKeepOrderRemoveGeometryRemoveMaterial = GameObjectAPI.disposeGameObjectKeepOrderRemoveGeometryRemoveMaterial;
@@ -999,6 +999,21 @@ let disposeGameObjectDisposeGeometryRemoveMaterial =
deferDisposeDisposeGeometryRemoveMaterial(gameObject, state);
};

let disposeGameObjectRemoveTexture =
(
gameObject: GameObjectPrimitiveType.gameObject,
state: StateDataMainType.state,
) => {
WonderLog.Contract.requireCheck(
() =>
WonderLog.(
Contract.(Operators.(_checkGameObjectShouldAlive(gameObject, state)))
),
IsDebugMainService.getIsDebug(StateDataMain.stateData),
);
deferDisposeRemoveTexture(gameObject, state);
};

let initGameObject =
(
gameObject: GameObjectPrimitiveType.gameObject,
@@ -52,11 +52,17 @@ let _disposeComponents =
true,
);
let state =
disposedBasicMaterialDataMap
|> batchDisposeBasicMaterialComponentFunc(state);
batchDisposeBasicMaterialComponentFunc(
state,
disposedBasicMaterialDataMap,
false,
);
let state =
disposedLightMaterialDataMap
|> batchDisposeLightMaterialComponentFunc(state);
batchDisposeLightMaterialComponentFunc(
state,
disposedLightMaterialDataMap,
false,
);
let (state, geometryNeedDisposeVboBufferArr) =
disposedGeometryDataMap
|> DisposeComponentGameObjectMainService.batchDisposeGeometryComponentData(
@@ -66,9 +72,9 @@ let _disposeComponents =
disposedSourceInstanceArray
|> DisposeComponentGameObjectMainService.batchDisposeSourceInstanceComponent(
state,
(false, false, false),
(false, false, false, false),
DisposeGameObjectMainService.batchDispose((
batchDisposeLightMaterialComponentFunc,
batchDisposeBasicMaterialComponentFunc,
batchDisposeLightMaterialComponentFunc,
)),
);
@@ -118,6 +124,7 @@ let _disposeGameObjects =
disposedUidArrayForKeepOrderRemoveGeometry,
disposedUidArrayForKeepOrderRemoveGeometryRemoveMaterial,
disposedUidArrayForDisposeGeometryRemoveMaterial,
disposedUidArrayForRemoveTexture,
} = gameObjectRecord;

let (
@@ -132,7 +139,7 @@ let _disposeGameObjects =
batchDisposeLightMaterialComponentFunc,
),
disposedUidArray,
(false, false, false),
(false, false, false, false),
);
let (
state,
@@ -146,7 +153,7 @@ let _disposeGameObjects =
batchDisposeLightMaterialComponentFunc,
),
disposedUidArrayForKeepOrder,
(true, false, false),
(true, false, false, false),
);
let (
state,
@@ -160,7 +167,7 @@ let _disposeGameObjects =
batchDisposeLightMaterialComponentFunc,
),
disposedUidArrayForKeepOrderRemoveGeometry,
(true, true, false),
(true, true, false, false),
);
let (
state,
@@ -174,7 +181,7 @@ let _disposeGameObjects =
batchDisposeLightMaterialComponentFunc,
),
disposedUidArrayForKeepOrderRemoveGeometryRemoveMaterial,
(true, true, true),
(true, true, true, false),
);
let (
state,
@@ -188,7 +195,21 @@ let _disposeGameObjects =
batchDisposeLightMaterialComponentFunc,
),
disposedUidArrayForDisposeGeometryRemoveMaterial,
(false, false, true),
(false, false, true, false),
);
let (
state,
geometryNeedDisposeVboBufferArrForRemoveTexture,
sourceInstanceNeedDisposeVboBufferArrForRemoveTexture,
) =
state
|> DisposeGameObjectMainService.batchDispose(
(
batchDisposeBasicMaterialComponentFunc,
batchDisposeLightMaterialComponentFunc,
),
disposedUidArrayForRemoveTexture,
(false, false, false, true),
);

let state = state |> DisposeGameObjectMainService.clearDeferDisposeData;
@@ -201,13 +222,15 @@ let _disposeGameObjects =
geometryNeedDisposeVboBufferArrForKeepOrderRemoveGeometry,
geometryNeedDisposeVboBufferArrForKeepOrderRemoveGeometryRemoveMaterial,
geometryNeedDisposeVboBufferArrForDisposeGeometryRemoveMaterial,
geometryNeedDisposeVboBufferArrForRemoveTexture,
|]),
sourceInstanceNeedDisposeVboBufferArrForNotKeepOrder
|> Js.Array.concatMany([|
sourceInstanceNeedDisposeVboBufferArrForKeepOrder,
sourceInstanceNeedDisposeVboBufferArrForKeepOrderRemoveGeometry,
sourceInstanceNeedDisposeVboBufferArrForKeepOrderRemoveGeometryRemoveMaterial,
sourceInstanceNeedDisposeVboBufferArrForDisposeGeometryRemoveMaterial,
sourceInstanceNeedDisposeVboBufferArrForRemoveTexture,
|]),
);
};
@@ -74,6 +74,7 @@ type gameObjectRecord = {
mutable disposedUidArrayForKeepOrderRemoveGeometryRemoveMaterial:
array(int),
mutable disposedUidArrayForDisposeGeometryRemoveMaterial: array(int),
mutable disposedUidArrayForRemoveTexture: array(int),
mutable disposedBasicCameraViewArray: array(int),
mutable disposedTransformArray: array(int),
mutable disposedTransformArrayForKeepOrder: array(int),
@@ -15,6 +15,7 @@ let create = () => {
WonderCommonlib.ArrayService.createEmpty(),
disposedUidArrayForDisposeGeometryRemoveMaterial:
WonderCommonlib.ArrayService.createEmpty(),
disposedUidArrayForRemoveTexture: WonderCommonlib.ArrayService.createEmpty(),
disposedScriptArray: WonderCommonlib.ArrayService.createEmpty(),
disposedBasicCameraViewArray: WonderCommonlib.ArrayService.createEmpty(),
disposedTransformArray: WonderCommonlib.ArrayService.createEmpty(),
@@ -65,6 +66,7 @@ let deepCopyForRestore =
disposedUidArrayForKeepOrderRemoveGeometry,
disposedUidArrayForKeepOrderRemoveGeometryRemoveMaterial,
disposedUidArrayForDisposeGeometryRemoveMaterial,
disposedUidArrayForRemoveTexture,
disposedBasicCameraViewArray,
disposedTransformArray,
disposedTransformArrayForKeepOrder,
@@ -117,6 +119,10 @@ let deepCopyForRestore =
disposedUidArrayForDisposeGeometryRemoveMaterial:
disposedUidArrayForDisposeGeometryRemoveMaterial
|> WonderCommonlib.MutableSparseMapService.copy,
/* TODO test */
disposedUidArrayForRemoveTexture:
disposedUidArrayForRemoveTexture
|> WonderCommonlib.MutableSparseMapService.copy,
disposedBasicCameraViewArray:
disposedBasicCameraViewArray
|> WonderCommonlib.MutableSparseMapService.copy,
@@ -319,17 +319,20 @@ let batchDisposeGeometryComponent =
state,
);

let batchDisposeBasicMaterialComponentData = (state, compnentDataMap) =>
let batchDisposeBasicMaterialComponentData =
(state, compnentDataMap, isRemoveTexture) =>
DisposeBasicMaterialMainService.handleBatchDisposeComponentData(.
isRemoveTexture,
compnentDataMap,
state,
);

let batchDisposeBasicMaterialComponentDataForWorker =
(state, componentDataMap) => {
(state, componentDataMap, isRemoveTexture) => {
open BasicMaterialType;
let state =
DisposeBasicMaterialMainService.handleBatchDisposeComponentData(.
isRemoveTexture,
componentDataMap,
state,
);
@@ -362,17 +365,20 @@ let batchDisposeBasicMaterialComponent =
state,
);

let batchDisposeLightMaterialComponentData = (state, componentDataMap) =>
let batchDisposeLightMaterialComponentData =
(state, componentDataMap, isRemoveTexture) =>
DisposeLightMaterialMainService.handleBatchDisposeComponentData(.
isRemoveTexture,
componentDataMap,
state,
);

let batchDisposeLightMaterialComponentDataForWorker =
(state, componentDataMap) => {
(state, componentDataMap, isRemoveTexture) => {
open LightMaterialType;
let state =
DisposeLightMaterialMainService.handleBatchDisposeComponentData(.
isRemoveTexture,
componentDataMap,
state,
);
@@ -434,13 +440,13 @@ let batchDisposePointLightComponent =
let batchDisposeSourceInstanceComponent =
(
state: StateDataMainType.state,
(isKeepOrder, isRemoveGeometry, isRemoveMaterial),
(isKeepOrder, isRemoveGeometry, isRemoveMaterial, isRemoveTexture),
disposeGameObjectFunc,
componentArray: array(component),
) =>
DisposeSourceInstanceMainService.handleBatchDisposeComponent(.
componentArray,
(isKeepOrder, isRemoveGeometry, isRemoveMaterial),
(isKeepOrder, isRemoveGeometry, isRemoveMaterial, isRemoveTexture),
disposeGameObjectFunc,
state,
);
@@ -23,7 +23,7 @@ let _getSharableComponentDataArr =
let _batchDisposeSharableComponents =
(
uidArray,
(isRemoveGeometry, isRemoveMaterial),
(isRemoveGeometry, isRemoveMaterial, isRemoveTexture),
(
batchDisposeBasicMaterialComponentFunc,
batchDisposeLightMaterialComponentFunc,
@@ -64,7 +64,11 @@ let _batchDisposeSharableComponents =
state,
basicMaterialDataMap,
) :
batchDisposeBasicMaterialComponentFunc(state, basicMaterialDataMap);
batchDisposeBasicMaterialComponentFunc(
state,
basicMaterialDataMap,
isRemoveTexture,
);

let lightMaterialDataMap =
_getSharableComponentDataArr(
@@ -79,14 +83,24 @@ let _batchDisposeSharableComponents =
state,
lightMaterialDataMap,
) :
batchDisposeLightMaterialComponentFunc(state, lightMaterialDataMap);
batchDisposeLightMaterialComponentFunc(
state,
lightMaterialDataMap,
isRemoveTexture,
);

(state, geometryNeedDisposeVboBufferArr);
};

let batchDispose =
(
(uidArray: array(int), isKeepOrder, isRemoveGeometry, isRemoveMaterial),
(
uidArray: array(int),
isKeepOrder,
isRemoveGeometry,
isRemoveMaterial,
isRemoveTexture,
),
(
batchDisposeBasicMaterialComponentFunc,
batchDisposeLightMaterialComponentFunc,
@@ -104,7 +118,7 @@ let batchDispose =
let (state, geometryNeedDisposeVboBufferArr) =
_batchDisposeSharableComponents(
uidArray,
(isRemoveGeometry, isRemoveMaterial),
(isRemoveGeometry, isRemoveMaterial, isRemoveTexture),
(
batchDisposeBasicMaterialComponentFunc,
batchDisposeLightMaterialComponentFunc,
@@ -176,7 +190,7 @@ let batchDispose =
)
|> DisposeComponentGameObjectMainService.batchDisposeSourceInstanceComponent(
state,
(isKeepOrder, isRemoveGeometry, isRemoveMaterial),
(isKeepOrder, isRemoveGeometry, isRemoveMaterial, isRemoveTexture),
batchDisposeFunc((
batchDisposeBasicMaterialComponentFunc,
batchDisposeLightMaterialComponentFunc,
@@ -21,7 +21,7 @@ let rec batchDispose =
batchDisposeLightMaterialComponentFunc,
),
uidArray: array(int),
(isKeepOrder, isRemoveGeometry, isRemoveMaterial),
(isKeepOrder, isRemoveGeometry, isRemoveMaterial, isRemoveTexture),
state,
) => {
let state = state |> _setDisposedUidMap(uidArray);
@@ -36,7 +36,7 @@ let rec batchDispose =
) =
state
|> DisposeGameObjectComponentMainService.batchDispose(
(uidArray, isKeepOrder, isRemoveGeometry, isRemoveMaterial),
(uidArray, isKeepOrder, isRemoveGeometry, isRemoveMaterial, isRemoveTexture),
(
batchDisposeBasicMaterialComponentFunc,
batchDisposeLightMaterialComponentFunc,
@@ -75,6 +75,9 @@ let clearDeferDisposeData = state => {
WonderCommonlib.ArrayService.createEmpty(),
disposedUidArrayForDisposeGeometryRemoveMaterial:
WonderCommonlib.ArrayService.createEmpty(),
/* TODO test */
disposedUidArrayForRemoveTexture:
WonderCommonlib.ArrayService.createEmpty(),
disposedBasicCameraViewArray: WonderCommonlib.ArrayService.createEmpty(),
disposedTransformArray: WonderCommonlib.ArrayService.createEmpty(),
disposedTransformArrayForKeepOrder:
@@ -129,4 +132,11 @@ let deferDisposeDisposeGeometryRemoveMaterial = (uid: int, state) => {
state.gameObjectRecord.disposedUidArrayForDisposeGeometryRemoveMaterial
|> ArrayService.push(uid);
state;
};

let deferDisposeRemoveTexture = (uid: int, state) => {
state.gameObjectRecord.disposedUidArrayForRemoveTexture =
state.gameObjectRecord.disposedUidArrayForRemoveTexture
|> ArrayService.push(uid);
state;
};

0 comments on commit 8818438

Please sign in to comment.
You can’t perform that action at this time.