Skip to content

Commit

Permalink
fix(inspector): fix "remove geometry component": remove instead of di…
Browse files Browse the repository at this point in the history
…spose geometry
  • Loading branch information
yyc-git committed Mar 9, 2019
1 parent f56d2d2 commit c108770
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let removeComponentByType =

| Geometry =>
(editorState, engineState)
|> GameObjectLogicService.disposeGeometry(
|> GameObjectLogicService.removeGeometry(
currentSceneTreeNode,
engineState
|> GameObjectComponentEngineService.unsafeGetGeometryComponent(
Expand Down
4 changes: 2 additions & 2 deletions src/service/stateTuple/logic/GameObjectLogicService.re
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ let disposeRenderGroup =
|> InspectorRenderGroupUtils.disposeRenderGroup(gameObject, materialType),
);

let disposeGeometry =
let removeGeometry =
(gameObject, geometryComponent, (editorState, engineState)) => (
editorState
|> InspectorEditorService.removeComponentTypeToMap(
gameObject,
InspectorComponentType.Geometry,
),
engineState
|> GameObjectComponentEngineService.disposeGeometryComponent(
|> GameObjectComponentEngineService.removeGeometryComponent(
gameObject,
geometryComponent,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,35 @@ let _ =
|> StateLogicService.getEngineStateToGetData
|> expect == true
);
test(
"test click remove geometry component, current gameObject shouldn't has it",
() => {
MainEditorInspectorRemoveComponentTool.removeGeometryComponent();

GameObjectComponentEngineService.hasGeometryComponent(
GameObjectTool.unsafeGetCurrentSceneTreeNode(),
)
|> StateLogicService.getEngineStateToGetData
|> expect == false;
describe("test click remove geometry component", () => {
test("current gameObject shouldn't has it", () => {
MainEditorInspectorRemoveComponentTool.removeGeometryComponent();

GameObjectComponentEngineService.hasGeometryComponent(
GameObjectTool.unsafeGetCurrentSceneTreeNode(),
)
|> StateLogicService.getEngineStateToGetData
|> expect == false;
});

describe("if remove geometry from all its gameObjects", () =>
test("geometry component shouldn't be disposed", () => {
let geometry =
GameObjectTool.getCurrentSceneTreeNodeGeometry();
let secondCube =
MainEditorSceneTool.getSecondCube
|> StateLogicService.getEngineStateToGetData;

MainEditorInspectorRemoveComponentTool.removeGeometryComponent();
GameObjectTool.setCurrentSceneTreeNode(secondCube);
MainEditorInspectorRemoveComponentTool.removeGeometryComponent();

GeometryToolEngine.isGeometryDisposed(geometry)
|> StateLogicService.getEngineStateToGetData
|> expect == false;
})
);
});
});
});
Expand Down

0 comments on commit c108770

Please sign in to comment.