Skip to content
Permalink
Browse files

perf(inspectorCanvas): optimize render inspector canvas: cache texture

CloneMaterialEngineLogicService->cloneLightMaterialToOtherEngineState: get diffuse map from cache or clone it and add to cache;
InspectorEngineGameObjectLogicService->disposeInspectorEngineContainerGameObjectAllChildren: disposeGameObject but remove texture;
update wonder.js, wonder-webgl version;
  • Loading branch information...
yyc-git committed May 27, 2019
1 parent 5c166e9 commit 51a9e1950df3dbc40082134e085f0cdab8ca8bd9
Showing with 303 additions and 116 deletions.
  1. +2 −2 package.json
  2. +7 −3 ...roject/composable_component/asset/composable_component/header/utils/AssetHeaderRemoveNodeUtils.re
  3. +7 −3 ...oject/composable_component/asset/composable_component/header/utils/ExtractAndRelateAssetsUtils.re
  4. +13 −11 ...omposable_component/assetTree_Inspector/atom_component/material_Inspector/ui/MaterialInspector.re
  5. +22 −19 ...onent/assetTree_Inspector/atom_component/material_Inspector/utils/MaterialInspectorEngineUtils.re
  6. +9 −7 ...nspector/composable_component/assetTree_Inspector/atom_component/wdb_inspector/ui/WDBInspector.re
  7. +19 −10 ...sable_component/assetTree_Inspector/atom_component/wdb_inspector/utils/WDBInspectorEngineUtils.re
  8. +7 −1 src/service/record/editor/data/InspectorCanvasType.re
  9. +2 −0 src/service/state/editor/CreateEditorStateEditorService.re
  10. +1 −0 src/service/state/engine/SourceTextureEngineService.re
  11. +15 −9 src/service/state/engine/gameObject/GameObjectEngineService.re
  12. +7 −3 src/service/stateTuple/logic/asset/WDBAssetLogicService.re
  13. +28 −15 src/service/stateTuple/logic/engine/CloneGameObjectLogicService.re
  14. +47 −15 src/service/stateTuple/logic/engine/CloneMaterialEngineLogicService.re
  15. +22 −7 src/service/stateTuple/logic/engine/CloneRenderGroupEngineLogicService.re
  16. +4 −3 src/service/stateTuple/logic/engine/InspectorEngineGameObjectLogicService.re
  17. +77 −0 src/service/stateTuple/logic/inspectorCanvas/SourceTextureCacheInspectorCanvasLogicService.re
  18. +9 −6 ...omponent/material_inspector/atom_component/basic_material/mainEditorBasicMaterialForAsset_test.re
  19. +5 −2 ...ctor/atom_component/material_inspector/atom_component/tool/MainEditorLightMaterialForAssetTool.re
@@ -74,11 +74,11 @@
"wonder-commonlib": "^0.2.32",
"wonder-hotkey": "^0.0.1",
"wonder-log": "^0.2.11",
"wonder.js": "1.1.0-alpha.8"
"wonder.js": "1.1.0-alpha.9"
},
"resolutions": {
"wonder-log": "^0.2.11",
"wonder-webgl": "^0.0.10",
"wonder-webgl": "^0.0.11",
"wonder-bs-sinon": "0.1.9",
"component-classes": "1.2.5",
"wonder-commonlib": "0.2.32",
@@ -27,14 +27,18 @@ let _createAllMaterialSnapshot =
engineState,
(editorState, inspectorEngineState),
) => {
let inspectorEngineState =
let (editorState, inspectorEngineState) =
(editorState, inspectorEngineState)
|> AssetTreeInspectorUtils.disposeContainerGameObjectAllChildrenAndReallocateCPUMemory
|> MaterialInspectorEngineUtils.createMaterialSphereIntoInspectorCanvas(
MaterialDataAssetType.LightMaterial,
material,
(editorState, engineState),
)
editorState,
engineState,
);

let inspectorEngineState =
inspectorEngineState
|> StateLogicService.renderInspectorEngineStateAndReturnState;

let editorState =
@@ -655,14 +655,18 @@ module AssetTree = {
~engineState,
);

let inspectorEngineState =
let (editorState, inspectorEngineState) =
(editorState, inspectorEngineState)
|> AssetTreeInspectorUtils.disposeContainerGameObjectAllChildrenAndReallocateCPUMemory
|> MaterialInspectorEngineUtils.createMaterialSphereIntoInspectorCanvas(
MaterialDataAssetType.LightMaterial,
material,
(editorState, engineState),
)
editorState,
engineState,
);

let inspectorEngineState =
inspectorEngineState
|> StateLogicService.renderInspectorEngineStateAndReturnState;

let editorState =
@@ -10,17 +10,19 @@ module Method = {
AssetTreeInspectorUtils.showInspectorCanvas();

Console.tryCatch(
() =>
StateInspectorEngineService.unsafeGetState()
|> MaterialInspectorEngineUtils.createMaterialSphereIntoInspectorCanvas(
type_,
materialComponent,
(
StateEditorService.getState(),
StateEngineService.unsafeGetState(),
),
)
|> StateLogicService.refreshInspectorEngineState,
() => {
let (editorState, inspectorEngineState) =
MaterialInspectorEngineUtils.createMaterialSphereIntoInspectorCanvas(
type_,
materialComponent,
StateEditorService.getState(),
StateEngineService.unsafeGetState(),
StateInspectorEngineService.unsafeGetState(),
);

editorState |> StateEditorService.setState |> ignore;
inspectorEngineState |> StateLogicService.refreshInspectorEngineState;
},
e => Console.throwFatal(e) |> ignore,
);
};
@@ -37,31 +37,31 @@ let _createLightMaterialSphereIntoInspectorCanvas =
(
materialComponent,
containerGameObject,
editorState,
engineState,
inspectorEngineState,
) => {
let (lightMaterial, inspectorEngineState) =
let (lightMaterial, editorState, inspectorEngineState) =
CloneMaterialEngineLogicService.cloneLightMaterialToOtherEngineState(
materialComponent,
editorState,
engineState,
inspectorEngineState,
);

inspectorEngineState
|> _createSphereWithClonedMaterial(
lightMaterial,
GameObjectComponentEngineService.addLightMaterialComponent,
containerGameObject,
);
(
editorState,
inspectorEngineState
|> _createSphereWithClonedMaterial(
lightMaterial,
GameObjectComponentEngineService.addLightMaterialComponent,
containerGameObject,
),
);
};

let createMaterialSphereIntoInspectorCanvas =
(
type_,
materialComponent,
(editorState, engineState),
inspectorEngineState,
) => {
(type_, materialComponent, editorState, engineState, inspectorEngineState) => {
WonderLog.Contract.requireCheck(
() =>
WonderLog.(
@@ -96,18 +96,21 @@ let createMaterialSphereIntoInspectorCanvas =
|> ContainerGameObjectInspectorCanvasEditorService.unsafeGetContainerGameObject;

switch (type_) {
| BasicMaterial =>
_createBasicMaterialSphereIntoInspectorCanvas(
materialComponent,
containerGameObject,
engineState,
inspectorEngineState,
| BasicMaterial => (
editorState,
_createBasicMaterialSphereIntoInspectorCanvas(
materialComponent,
containerGameObject,
engineState,
inspectorEngineState,
),
)

| LightMaterial =>
_createLightMaterialSphereIntoInspectorCanvas(
materialComponent,
containerGameObject,
editorState,
engineState,
inspectorEngineState,
)
@@ -18,15 +18,17 @@ module Method = {

Console.tryCatch(
() => {
StateInspectorEngineService.unsafeGetState()
|> WDBInspectorEngineUtils.createWDBIntoInspectorCanvas(
wdbGameObject,
(
let (editorState, inspectorEngineState) =
StateInspectorEngineService.unsafeGetState()
|> WDBInspectorEngineUtils.createWDBIntoInspectorCanvas(
wdbGameObject,
StateEditorService.getState(),
StateEngineService.unsafeGetState(),
),
)
|> StateLogicService.refreshInspectorEngineState;
);

editorState |> StateEditorService.setState |> ignore;

inspectorEngineState |> StateLogicService.refreshInspectorEngineState;

_updateSnapshot(currentNodeId, dispatchFunc);
},
@@ -1,8 +1,9 @@
let rec _iterateCreateNewWDBGameObject =
(gameObject, engineState, inspectorEngineState) => {
let (newGameObject, inspectorEngineState) =
(gameObject, editorState, engineState, inspectorEngineState) => {
let (newGameObject, editorState, inspectorEngineState) =
CloneGameObjectLogicService.cloneGameObjectToOtherEngineState(
gameObject,
editorState,
engineState,
inspectorEngineState,
);
@@ -15,10 +16,14 @@ let rec _iterateCreateNewWDBGameObject =
engineState
|> HierarchyGameObjectEngineService.getChildren(gameObject)
|> Js.Array.reduce(
((newGameObject, inspectorEngineState), gameObjectChild) => {
let (newGameObjectChild, inspectorEngineState) =
(
(newGameObject, editorState, inspectorEngineState),
gameObjectChild,
) => {
let (newGameObjectChild, editorState, inspectorEngineState) =
_iterateCreateNewWDBGameObject(
gameObjectChild,
editorState,
engineState,
inspectorEngineState,
);
@@ -30,11 +35,11 @@ let rec _iterateCreateNewWDBGameObject =
newGameObjectChild,
);

(newGameObject, inspectorEngineState);
(newGameObject, editorState, inspectorEngineState);
},
(newGameObject, inspectorEngineState),
(newGameObject, editorState, inspectorEngineState),
) :
(newGameObject, inspectorEngineState);
(newGameObject, editorState, inspectorEngineState);
};

let _setCameraFocusWDBGameObject = (newWDBGameObject, inspectorEngineState) => {
@@ -46,14 +51,15 @@ let _setCameraFocusWDBGameObject = (newWDBGameObject, inspectorEngineState) => {
};

let createWDBIntoInspectorCanvas =
(wdbGameObject, (editorState, engineState), inspectorEngineState) => {
(wdbGameObject, editorState, engineState, inspectorEngineState) => {
let containerGameObject =
editorState
|> ContainerGameObjectInspectorCanvasEditorService.unsafeGetContainerGameObject;

let (newWDBGameObject, inspectorEngineState) =
let (newWDBGameObject, editorState, inspectorEngineState) =
_iterateCreateNewWDBGameObject(
wdbGameObject,
editorState,
engineState,
inspectorEngineState,
);
@@ -64,5 +70,8 @@ let createWDBIntoInspectorCanvas =
newWDBGameObject,
);

inspectorEngineState |> _setCameraFocusWDBGameObject(newWDBGameObject);
(
editorState,
inspectorEngineState |> _setCameraFocusWDBGameObject(newWDBGameObject),
);
};
@@ -1 +1,7 @@
type inspectorCanvasRecord = {containerGameObject: option(int)};
type clonedBasicSourceTextureInInspectorEngineState = Wonderjs.BasicSourceTextureType.basicSourceTexture;

type inspectorCanvasRecord = {
containerGameObject: option(int),
basicSourceTextureCacheMap:
WonderCommonlib.ImmutableSparseMapService.t(clonedBasicSourceTextureInInspectorEngineState),
};
@@ -3,6 +3,8 @@ open EditorType;
let create = () => {
inspectorCanvasRecord: {
containerGameObject: None,
basicSourceTextureCacheMap:
WonderCommonlib.ImmutableSparseMapService.createEmpty(),
},
imgCanvasRecord: {
imgContext: None,
@@ -0,0 +1 @@
let isBasicSourceTextureIndex = Wonderjs.IndexSourceTextureMainService.isBasicSourceTextureIndex;
@@ -8,6 +8,8 @@ let isGameObjectAlive = GameObjectAPI.isGameObjectAlive;

let disposeGameObject = GameObjectAPI.disposeGameObject;

let disposeGameObjectRemoveTexture = GameObjectAPI.disposeGameObjectRemoveTexture;

let cloneGameObject =
(gameObject, count, isShareMaterial, engineState)
: (array(array('a)), Wonderjs.StateDataMainType.state) => {
@@ -179,7 +181,7 @@ let getGameObjectActiveBasicCameraView = (gameObject, engineState) => {
_getGameObjectActiveBasicCameraViews(gameObject, engineState);

activeBasicCameraViews |> Js.Array.length === 0 ?
None : Array.unsafe_get(activeBasicCameraViews, 0) |. Some;
None : Array.unsafe_get(activeBasicCameraViews, 0)->Some;
};

let setAllGameObjectsIsRenderIfHasMeshRenderer =
@@ -193,14 +195,18 @@ let setAllGameObjectsIsRenderIfHasMeshRenderer =
|> GameObjectComponentEngineService.hasMeshRendererComponent(
gameObject,
) ?
engineState
|> GameObjectComponentEngineService.unsafeGetMeshRendererComponent(
gameObject,
)
|. MeshRendererEngineService.setMeshRendererIsRender(
isRender,
engineState,
) :
(
engineState
|> GameObjectComponentEngineService.unsafeGetMeshRendererComponent(
gameObject,
)
)
->(
MeshRendererEngineService.setMeshRendererIsRender(
isRender,
engineState,
)
) :
engineState;

_iterateGameObjectArr(
@@ -54,13 +54,17 @@ let createWDBNodeUseImageDataMapSnapshot =

let createWDBNodeUseCreatedSnapshot =
((wdbNodeId, name, gameObject, parentFolderNode), editorState) => {
let inspectorEngineState =
let (editorState, inspectorEngineState) =
(editorState, StateInspectorEngineService.unsafeGetState())
|> AssetTreeInspectorUtils.disposeContainerGameObjectAllChildrenAndReallocateCPUMemory
|> WDBInspectorEngineUtils.createWDBIntoInspectorCanvas(
gameObject,
(editorState, StateEngineService.unsafeGetState()),
)
editorState,
StateEngineService.unsafeGetState(),
);

let inspectorEngineState =
inspectorEngineState
|> StateLogicService.renderInspectorEngineStateAndReturnState;

let editorState =

0 comments on commit 51a9e19

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