Commit bbff5e2d authored by Christian Winter's avatar Christian Winter

now possible to only change the position of instances when rotating or scaling

parent a02dcebe
Pipeline #4766874 passed with stage
in 49 seconds
......@@ -34,7 +34,8 @@ class LineManipulator {
for (let instance of Selection.data.prefabInstances) {
instance.transform.position = this.rotatePositionByAngle(instance.transform.position, rotationCenter, degrees);
instance.transform.rotation += degrees;
if (!Preferences.onlyTransformPrefabInstancePosition)
instance.transform.rotation += degrees;
}
Renderer.redraw();
......@@ -76,7 +77,8 @@ class LineManipulator {
for (let instance of Selection.data.prefabInstances) {
instance.transform.position = this.scalePoint(instance.transform.position, center, scaleVector);
instance.transform.scale = instance.transform.scale.multiplyVector(scaleVector);
if (!Preferences.onlyTransformPrefabInstancePosition)
instance.transform.scale = instance.transform.scale.multiplyVector(scaleVector);
}
Renderer.redraw();
......
......@@ -69,6 +69,13 @@ class PrefabInstance {
return false;
}
instanceSpaceForPosition(pos) {
pos = pos.addVector(this.transform.position);
pos = pos.scaleFrom(this.transform.position, this.transform.scale);
pos = pos.rotateAround(this.transform.position, this.transform.rotation);
return pos;
}
get bounds() {
let min = new Vector2(Infinity, Infinity);
let max = new Vector2(-Infinity, -Infinity);
......
......@@ -969,14 +969,13 @@
}
static drawPrefabInstances(instances, outlinecolor, deltaPos, deltaRot, deltaScale, center) {
let positionOnly = false;
// draw prefab instances
for (let instance of instances) {
let pos;
if (!Logic.isPreviewing())
{
// transform from prefab to instance
let pos = instance.transform.position;
pos = instance.transform.position;
// normal transform operation
if (deltaPos)
......@@ -993,15 +992,8 @@
if (!Logic.isPreviewing()) {
for (let line of instance.reference.lines) {
// transform from prefab to instance
let start = line.start.position;
start = start.addVector(instance.transform.position);
start = start.scaleFrom(instance.transform.position, instance.transform.scale);
start = start.rotateAround(instance.transform.position, instance.transform.rotation);
let end = line.end.position;
end = end.addVector(instance.transform.position);
end = end.scaleFrom(instance.transform.position, instance.transform.scale);
end = end.rotateAround(instance.transform.position, instance.transform.rotation);
let start = instance.instanceSpaceForPosition(line.start.position);
let end = instance.instanceSpaceForPosition(line.end.position);
// normal transformations
if (deltaPos) {
......@@ -1011,10 +1003,20 @@
if (deltaRot) {
start = start.rotateAround(center, deltaRot);
end = end.rotateAround(center, deltaRot);
if (Preferences.onlyTransformPrefabInstancePosition){
start = start.rotateAround(pos, -deltaRot);
end = end.rotateAround(pos, -deltaRot);
}
}
if (deltaScale) {
start = start.scaleFrom(center, deltaScale);
end = end.scaleFrom(center, deltaScale);
if (Preferences.onlyTransformPrefabInstancePosition) {
start = start.scaleFrom(pos, deltaScale.oneDividedByThisVector());
end = end.scaleFrom(pos, deltaScale.oneDividedByThisVector());
}
}
this.drawLineFromTo(start, end, line.thickness + Settings.prefabOutlineSize, outlinecolor);
......@@ -1038,11 +1040,11 @@
start = start.addVector(deltaPos);
end = end.addVector(deltaPos);
}
if (deltaRot) {
if (deltaRot && !Preferences.onlyTransformPrefabInstancePosition) {
start = start.rotateAround(center, deltaRot);
end = end.rotateAround(center, deltaRot);
}
if (deltaScale) {
if (deltaScale && !Preferences.onlyTransformPrefabInstancePosition) {
start = start.scaleFrom(center, deltaScale);
end = end.scaleFrom(center, deltaScale);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment