Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: excludes gizmo children for worldAABB updating #921

Merged
merged 2 commits into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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