Skip to content
Permalink
Browse files

feat(wdb): finish clone wdb gameObject to other engine state

  • Loading branch information...
AmyOrz committed Apr 19, 2019
1 parent abdb9a8 commit 58c609fbf0246a0b210cdd752bd419b98cc06ab0
Showing with 422 additions and 87 deletions.
  1. +1 −1 ...nspector/composable_component/assetTree_Inspector/atom_component/wdb_inspector/ui/WDBInspector.re
  2. +32 −5 ...sable_component/assetTree_Inspector/atom_component/wdb_inspector/utils/WDBInspectorEngineUtils.re
  3. +1 −1 ...r/composable_component/sceneTree_Inspector/composable_component/geometry/ui/MainEditorGeometry.re
  4. +1 −1 ...component/renderGroup/material/composable_component/utils/MaterialDragTextureEventHandlerUtils.re
  5. +3 −3 src/core/composable_component/utils/RelateGameObjectAndGeometryAssetUtils.re
  6. +0 −1 src/core/job/init/InitHotKeysJob.re
  7. +1 −1 src/core/job/init/InitPickingJob.re
  8. +5 −9 src/core/utils/engine/job/init/initHotKeysJob/FocusUtils.re
  9. +1 −1 src/core/utils/engine/job/init/initPickingJob/AABBShapeUtils.re
  10. +3 −3 src/core/utils/engine/job/init/initPickingJob/MeshUtils.re
  11. +2 −2 src/core/utils/engine/job/init/initTransformGizmosJob/rotation/CreateRotationGizmosUtils.re
  12. +1 −1 src/core/utils/engine/job/init/initTransformGizmosJob/translation/SelectTranslationGizmoUtils.re
  13. +31 −18 src/service/state/engine/GeometryEngineService.re
  14. +6 −1 src/service/state/engine/TransformEngineService.re
  15. +12 −0 src/service/state/inspectorEngine/GameObjectInspectorEngineService.re
  16. +8 −8 src/service/stateTuple/logic/asset/GeometryAssetLogicService.re
  17. +83 −3 src/service/stateTuple/logic/engine/CloneGameObjectLogicService.re
  18. +49 −0 src/service/stateTuple/logic/engine/CloneGeometryEngineLogicService.re
  19. +16 −0 src/service/stateTuple/logic/engine/CloneMeshRenderEngineLogicService.re
  20. +106 −0 src/service/stateTuple/logic/engine/CloneRenderGroupEngineLogicService.re
  21. +25 −0 src/service/stateTuple/logic/engine/CloneTransformEngineLogicService.re
  22. +2 −2 src/service/stateTuple/logic/geometry/GeometryLogicService.re
  23. +7 −0 ...ntegration/inspector/composable_component/assetTree_inspector/atom_component/wdbInspector_test.re
  24. +1 −1 ...roup/material/composable_component/light_material/ui/mainEditorLightMaterialForGameObject_test.re
  25. +2 −2 test/integration/job/gizmo/renderTransformGizmosJob_test.re
  26. +2 −2 test/integration/job/initEditorJob_test.re
  27. +6 −6 test/integration/job/initPickingJob/initPickingJob_test.re
  28. +1 −1 test/integration/job/reallocateCPUMemoryJob_test.re
  29. +4 −4 test/integration/redo_undo/asset/redo_undo_asset_removeWDB_test.re
  30. +1 −1 test/tool/MainEditorSceneTool.re
  31. +1 −1 test/tool/TransformGameObjectTool.re
  32. +8 −8 test/tool/engine/GeometryToolEngine.re
@@ -12,7 +12,7 @@ module Method = {
|> StateLogicService.refreshInspectorEngineState;
};

let willUnmount = AssetTreeInspectorUtils.hideInspectorCanvasAndDisposeContainerGameObjectAllChildren;
let willUnmount = AssetTreeInspectorUtils.hideInspectorCanvasAndDisposeContainerGameObjectAllChildren;
};

let component = ReasonReact.statelessComponent("WDBInspector");
@@ -6,7 +6,11 @@ let rec _iterateWDBGameObject =
engineState,
inspectorEngineState,
);
Js.log2("newGame", newGameObject );

let inspectorEngineState =
inspectorEngineState
|> GameObjectEngineService.initGameObject(newGameObject);
Js.log2("newGame", newGameObject);

engineState |> HierarchyGameObjectEngineService.hasChildren(gameObject) ?
engineState
@@ -34,14 +38,37 @@ let rec _iterateWDBGameObject =
(newGameObject, inspectorEngineState);
};

let _setCameraDistance = (newWDBGameObject, inspectorEngineState) => {
let camera =
GameObjectInspectorEngineService.unsafeGetCamera(inspectorEngineState);

let (_center, distance) =
inspectorEngineState |> FocusUtils.calcCenterAndDistance(newWDBGameObject);

inspectorEngineState
|> TransformEngineService.setLocalPosition(
(0., 0., distance),
GameObjectComponentEngineService.unsafeGetTransformComponent(
camera,
inspectorEngineState,
),
);
};

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

inspectorEngineState
|> HierarchyGameObjectEngineService.getChildren(7)
|> Js.log;
|> GameObjectEngineService.initGameObject(newWDBGameObject)
|> HierarchyGameObjectEngineService.addChild(
containerGameObject,
newWDBGameObject,
);

inspectorEngineState;
inspectorEngineState |> _setCameraDistance(newWDBGameObject);
};
@@ -12,7 +12,7 @@ module Method = {
let changeGeometry = MainEditorChangeGeometryEventHandler.MakeEventHandler.pushUndoStackWithNoCopyEngineState;

/* let _isValidGeometry = (geometry, engineState) =>
GeometryEngineService.getGeometryVertices(geometry, engineState)
GeometryEngineService.unsafeGetGeometryVertices(geometry, engineState)
|> Js.Typed_array.Float32Array.length > 0; */

let _isGameObjectLightMaterialComponentHasMap = (gameObject, engineState) => {
@@ -9,7 +9,7 @@ let _handleGeometryAddMap =
| None => handleSetMapFunc(materialComponent, textureComponent, engineState)
| Some(geometryComponent)
when
GeometryEngineService.getGeometryTexCoords(
GeometryEngineService.unsafeGetGeometryTexCoords(
geometryComponent,
engineState,
)
@@ -91,9 +91,9 @@ let replaceGeometryComponent =

let getGeometryData = (geometry, engineState) => (
GeometryEngineService.getGeometryName(geometry, engineState),
GeometryEngineService.getGeometryVertices(geometry, engineState),
GeometryEngineService.getGeometryNormals(geometry, engineState),
GeometryEngineService.getGeometryTexCoords(geometry, engineState),
GeometryEngineService.unsafeGetGeometryVertices(geometry, engineState),
GeometryEngineService.unsafeGetGeometryNormals(geometry, engineState),
GeometryEngineService.unsafeGetGeometryTexCoords(geometry, engineState),
);

let replaceWDBAssetGameObjectGeometryComponentToDefaultGeometryComponent =
@@ -92,7 +92,6 @@ let _getHandleFuncByHotKeyAction = hotKeyAction => {
FocusUtils.setEditorCameraFocusTargetGameObject(
editorState |> SceneViewEditorService.unsafeGetEditCamera,
currentSceneTreeNode,
editorState,
StateEngineService.unsafeGetState(),
)
|> StateLogicService.refreshEngineState
@@ -144,7 +144,7 @@ let _computeSphereShapeData = (allGameObjectData, (editorState, engineState)) =>
PickingEditorService.setSphereShape(
geometry,
SphereShapeUtils.setFromPoints(
GeometryEngineService.getGeometryVertices(
GeometryEngineService.unsafeGetGeometryVertices(
geometry,
engineState,
),
@@ -52,15 +52,16 @@ let _buildAllPointsAndLocalToWolrdMatrices = (targetGameObject, engineState) =>
);

(
engineState |> GeometryEngineService.getGeometryVertices(geometry),
engineState
|> GeometryEngineService.unsafeGetGeometryVertices(geometry),
engineState
|> TransformGameObjectEngineService.getLocalToWorldMatrixTypeArray(
gameObject,
),
);
});

let _calcCenterAndDistance = (targetGameObject, engineState) =>
let calcCenterAndDistance = (targetGameObject, engineState) =>
switch (
_buildAllPointsAndLocalToWolrdMatrices(targetGameObject, engineState)
) {
@@ -84,7 +85,7 @@ let _calcCenterAndDistance = (targetGameObject, engineState) =>
};

let setEditorCameraFocusTargetGameObject =
(editCamera, targetGameObject, editorState, engineState) => {
(editCamera, targetGameObject, engineState) => {
WonderLog.Contract.requireCheck(
() =>
WonderLog.(
@@ -114,14 +115,9 @@ let setEditorCameraFocusTargetGameObject =
editCamera,
engineState,
);
let targetGameObjectTransform =
engineState
|> GameObjectComponentEngineService.unsafeGetTransformComponent(
targetGameObject,
);

let (center, distance) =
engineState |> _calcCenterAndDistance(targetGameObject);
engineState |> calcCenterAndDistance(targetGameObject);

_setArcballCameraControllerFocusRelatedAttribute(
editorCameraArcballControllerComponent,
@@ -74,7 +74,7 @@ let setFromGameObject = (gameObject, engineState) => {
);

let vertices =
GeometryEngineService.getGeometryVertices(geometry, engineState);
GeometryEngineService.unsafeGetGeometryVertices(geometry, engineState);

_forEachVertices(
vertices,
@@ -65,9 +65,9 @@ let checkIntersectMesh =
_checkIntersectMesh(
(geometry, localToWorldMatrixTypeArray, cullType, engineState),
(
GeometryEngineService.getGeometryVertices(geometry, engineState),
GeometryEngineService.getGeometryIndices16(geometry, engineState),
GeometryEngineService.getGeometryIndices32(geometry, engineState),
GeometryEngineService.unsafeGetGeometryVertices(geometry, engineState),
GeometryEngineService.unsafeGetGeometryIndices16(geometry, engineState),
GeometryEngineService.unsafeGetGeometryIndices32(geometry, engineState),
GeometryEngineService.getIndicesCount(geometry, engineState),
),
ray,
@@ -34,12 +34,12 @@ let _createCircleGeometry = engineState => {
let engineState =
engineState
|> GeometryEngineService.setGeometryVertices(
geometry,
Float32Array.make(vertices),
geometry,
)
|> GeometryEngineService.setGeometryIndices16(
geometry,
Uint16Array.make(indices),
geometry,
);

(engineState, geometry);
@@ -34,7 +34,7 @@ let isSelectTranslationAxisGizmo =
{
let aabb =
AABBShapeUtils.setFromPoints(
GeometryEngineService.getGeometryVertices(
GeometryEngineService.unsafeGetGeometryVertices(
GameObjectComponentEngineService.unsafeGetGeometryComponent(
gameObject,
engineState,
@@ -33,28 +33,45 @@ let createConeGeometry = GeometryAPI.createConeGeometry;

let createPlaneGeometry = GeometryAPI.createPlaneGeometry;

let getGeometryVertices = GeometryAPI.getGeometryVertices;
let unsafeGetGeometryVertices = GeometryAPI.getGeometryVertices;

let setGeometryVertices = GeometryAPI.setGeometryVertices;
let setGeometryVertices = (value, component, engineState) =>
GeometryAPI.setGeometryVertices(component, value, engineState);

let getGeometryNormals = GeometryAPI.getGeometryNormals;
let unsafeGetGeometryNormals = GeometryAPI.getGeometryNormals;

let setGeometryNormals = GeometryAPI.setGeometryNormals;
let setGeometryNormals = (value, component, engineState) =>
GeometryAPI.setGeometryNormals(component, value, engineState);

let getGeometryTexCoords = GeometryAPI.getGeometryTexCoords;
let unsafeGetGeometryTexCoords = GeometryAPI.getGeometryTexCoords;

let setGeometryTexCoords = (value, component, engineState) =>
GeometryAPI.setGeometryTexCoords(component, value, engineState);

let hasIndices16 = GeometryAPI.hasGeometryIndices16;

let unsafeGetGeometryIndices16 = GeometryAPI.getGeometryIndices16;

let setGeometryTexCoords = GeometryAPI.setGeometryTexCoords;
let getGeometryIndices16 = (geometryComponent, engineState) =>
engineState |> hasIndices16(geometryComponent) ?
Some(unsafeGetGeometryIndices16(geometryComponent, engineState)) : None;

let getGeometryIndices16 = GeometryAPI.getGeometryIndices16;
let setGeometryIndices16 = (value, component, engineState) =>
GeometryAPI.setGeometryIndices16(component, value, engineState);

let setGeometryIndices16 = GeometryAPI.setGeometryIndices16;
let hasIndices32 = GeometryAPI.hasGeometryIndices32;

let getGeometryIndices32 = GeometryAPI.getGeometryIndices32;
let unsafeGetGeometryIndices32 = GeometryAPI.getGeometryIndices32;

let setGeometryIndices32 = GeometryAPI.setGeometryIndices32;
let getGeometryIndices32 = (geometryComponent, engineState) =>
engineState |> hasIndices32(geometryComponent) ?
Some(unsafeGetGeometryIndices32(geometryComponent, engineState)) : None;

let setGeometryIndices32 = (value, component, engineState) =>
GeometryAPI.setGeometryIndices32(component, value, engineState);

let hasGeometryTexCoords = (geometry, engineState) =>
getGeometryTexCoords(geometry, engineState) |> Float32Array.length > 0;
unsafeGetGeometryTexCoords(geometry, engineState) |> Float32Array.length > 0;

let getAllGeometrys = GeometryAPI.getAllGeometrys;

@@ -98,8 +115,8 @@ let createGridPlaneGameObject = ((size, step, y), color, engineState) => {

let engineState =
engineState
|> setGeometryVertices(geometry, Float32Array.make(vertices))
|> setGeometryIndices16(geometry, Uint16Array.make(indices));
|> setGeometryVertices(Float32Array.make(vertices), geometry)
|> setGeometryIndices16(Uint16Array.make(indices), geometry);

let engineState =
engineState
@@ -152,8 +169,4 @@ let getIndicesCount = (geometry, engineState) => {
indicesInfos,
);
endIndex - startIndex;
};

let hasIndices16 = GeometryAPI.hasGeometryIndices16;

let hasIndices32 = GeometryAPI.hasGeometryIndices32;
};
@@ -61,7 +61,12 @@ let getGameObjectByTransform = Wonderjs.TransformAPI.unsafeGetTransformGameObjec

let getLocalRotation = Wonderjs.TransformAPI.getTransformLocalRotation;

let setLocalRotation = Wonderjs.TransformAPI.setTransformLocalRotation;
let setLocalRotation = (value, component, engineState) =>
Wonderjs.TransformAPI.setTransformLocalRotation(
component,
value,
engineState,
);

let getRotation = Wonderjs.TransformAPI.getTransformRotation;

@@ -0,0 +1,12 @@
let unsafeGetCamera = inspectorEngineState =>
inspectorEngineState
|> HierarchyGameObjectEngineService.getAllGameObjects(
inspectorEngineState |> SceneEngineService.getSceneGameObject,
)
|> Js.Array.filter(gameObject =>
GameObjectComponentEngineService.hasBasicCameraViewComponent(
gameObject,
inspectorEngineState,
)
)
|> ArrayService.unsafeGetFirst;
@@ -5,23 +5,23 @@ let isGeometryPointDataEqual = (points1, points2, getLengthFunc) =>

let _isGeometryVertexDataEqual = (geometry1, geometry2, engineState) =>
isGeometryPointDataEqual(
GeometryEngineService.getGeometryVertices(geometry1, engineState),
GeometryEngineService.getGeometryVertices(geometry2, engineState),
GeometryEngineService.unsafeGetGeometryVertices(geometry1, engineState),
GeometryEngineService.unsafeGetGeometryVertices(geometry2, engineState),
Float32Array.length,
)
&& isGeometryPointDataEqual(
GeometryEngineService.getGeometryNormals(geometry1, engineState),
GeometryEngineService.getGeometryNormals(geometry2, engineState),
GeometryEngineService.unsafeGetGeometryNormals(geometry1, engineState),
GeometryEngineService.unsafeGetGeometryNormals(geometry2, engineState),
Float32Array.length,
)
&& isGeometryPointDataEqual(
GeometryEngineService.getGeometryTexCoords(geometry1, engineState),
GeometryEngineService.getGeometryTexCoords(geometry2, engineState),
GeometryEngineService.unsafeGetGeometryTexCoords(geometry1, engineState),
GeometryEngineService.unsafeGetGeometryTexCoords(geometry2, engineState),
Float32Array.length,
)
&& isGeometryPointDataEqual(
GeometryEngineService.getGeometryIndices16(geometry1, engineState),
GeometryEngineService.getGeometryIndices16(geometry2, engineState),
GeometryEngineService.unsafeGetGeometryIndices16(geometry1, engineState),
GeometryEngineService.unsafeGetGeometryIndices16(geometry2, engineState),
Uint16Array.length,
);

0 comments on commit 58c609f

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