Skip to content

Commit

Permalink
Merge pull request #921 from actnwit/fix/worldaabb-updating
Browse files Browse the repository at this point in the history
fix: excludes gizmo children for worldAABB updating
  • Loading branch information
Yuki Shimada authored Nov 28, 2021
2 parents 6822189 + 7d3106b commit b7a5059
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
24 changes: 17 additions & 7 deletions src/foundation/components/SceneGraphComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class SceneGraphComponent extends Component {
private static __sceneGraphs: SceneGraphComponent[] = [];
public isAbleToBeParent: boolean;
private __children: Array<SceneGraphComponent> = [];
private __gizmoChildren: Array<SceneGraphComponent> = [];
private _worldMatrix: MutableMatrix44 = MutableMatrix44.dummy();
private _normalMatrix: MutableMatrix33 = MutableMatrix33.dummy();
private __isWorldMatrixUpToDate = false;
Expand Down Expand Up @@ -164,13 +165,22 @@ export default class SceneGraphComponent extends Component {
this.parent?.setWorldAABBDirtyParentRecursively();
}

addChild(sg: SceneGraphComponent) {
if (this.__children != null) {
sg.__parent = this;
this.__children.push(sg);
} else {
console.error('This is not allowed to have children.');
}
/**
* add a SceneGraph component as a child of this
* @param sg a SceneGraph component of Gizmo
*/
public addChild(sg: SceneGraphComponent): void {
sg.__parent = this;
this.__children.push(sg);
}

/**
* add a SceneGraph component as a child of this (But Gizmo only)
* @param sg a SceneGraph component of Gizmo
*/
_addGizmoChild(sg: SceneGraphComponent): void {
sg.__parent = this;
this.__gizmoChildren.push(sg);
}

get isTopLevel() {
Expand Down
2 changes: 1 addition & 1 deletion src/foundation/gizmos/AABBGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class AABBGizmo extends Gizmo {
]);
this.__topEntity.tryToSetUniqueName(`AABBGizmo_of_${this.__target.uniqueName}`, true);
this.__topEntity.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix = true;
this.__target.getSceneGraph().addChild(this.__topEntity.getSceneGraph());
this.__target.getSceneGraph()._addGizmoChild(this.__topEntity.getSceneGraph());

const meshComponent = this.__topEntity.getMesh();
AABBGizmo.__mesh = new Mesh();
Expand Down
2 changes: 1 addition & 1 deletion src/foundation/gizmos/LocatorGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class LocatorGizmo extends Gizmo {
]);
this.__topEntity.tryToSetUniqueName(`LocatorGizmo_of_${this.__target.uniqueName}`, true);
this.__topEntity.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix = true;
this.__target.getSceneGraph().addChild(this.__topEntity.getSceneGraph());
this.__target.getSceneGraph()._addGizmoChild(this.__topEntity.getSceneGraph());

const meshComponent = this.__topEntity.getMesh();
LocatorGizmo.__mesh = new Mesh();
Expand Down

0 comments on commit b7a5059

Please sign in to comment.