mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-30 08:20:24 +00:00
Adjust parent transform if parent is edited
This commit is contained in:
parent
5f7f9c3517
commit
ea29db89f5
1 changed files with 13 additions and 10 deletions
|
@ -166,29 +166,32 @@ namespace LayoutBXLYT
|
||||||
public void ApplyNewParentTransform()
|
public void ApplyNewParentTransform()
|
||||||
{
|
{
|
||||||
//Get the new transform and apply it
|
//Get the new transform and apply it
|
||||||
var transform = GetParentTransform();
|
|
||||||
// Translate += transform;
|
// Translate += transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetParentTransform(BasePane newParent)
|
public void ResetParentTransform(BasePane newParent)
|
||||||
{
|
{
|
||||||
//We need to get the difference in the parent transform and remove it to the current transform of this pane
|
//We need to get the difference in the parent transform and remove it to the current transform of this pane
|
||||||
var transform = GetParentTransform();
|
var transform = GetParentTransform(Parent);
|
||||||
var newParentTransform = newParent.GetParentTransform();
|
var newParentTransform = GetParentTransform(newParent);
|
||||||
Translate -= transform;
|
Translate += transform;
|
||||||
Translate += newParentTransform;
|
Translate -= newParentTransform;
|
||||||
|
|
||||||
|
Console.WriteLine($"newParentTransform {newParentTransform.X} {newParentTransform.Y} {newParentTransform.Z}");
|
||||||
|
Console.WriteLine($"transform {transform.X} {transform.Y} {transform.Z}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3F GetParentTransform() {
|
private Vector3F GetParentTransform(BasePane parent) {
|
||||||
return GetParentTransform(Vector3F.Zero);
|
return GetParentTransform(parent.Translate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3F GetParentTransform(Vector3F translate)
|
private Vector3F GetParentTransform(Vector3F translate)
|
||||||
{
|
{
|
||||||
if (Parent != null)
|
if (Parent != null)
|
||||||
return translate += Parent.GetParentTransform(translate);
|
translate = Parent.Translate + Parent.GetParentTransform(translate);
|
||||||
else
|
|
||||||
return translate;
|
return translate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KeepChildrenTransform(float newTransX, float newTransY)
|
public void KeepChildrenTransform(float newTransX, float newTransY)
|
||||||
|
|
Loading…
Reference in a new issue