Add support for multiple brush, model instance, and entity targets in transform operations
This commit is contained in:
@@ -1157,6 +1157,8 @@ export function getTransformTargetLabel(target: TransformTarget): string {
|
|||||||
switch (target.kind) {
|
switch (target.kind) {
|
||||||
case "brush":
|
case "brush":
|
||||||
return getBrushKindLabel(createBrushSnapshotFromTarget(target));
|
return getBrushKindLabel(createBrushSnapshotFromTarget(target));
|
||||||
|
case "brushes":
|
||||||
|
return `${target.items.length} Whitebox Solid${target.items.length === 1 ? "" : "s"}`;
|
||||||
case "brushFace":
|
case "brushFace":
|
||||||
return `Whitebox Face (${getBrushFaceLabel(createBrushSnapshotFromTarget(target), target.faceId)})`;
|
return `Whitebox Face (${getBrushFaceLabel(createBrushSnapshotFromTarget(target), target.faceId)})`;
|
||||||
case "brushEdge":
|
case "brushEdge":
|
||||||
@@ -1165,10 +1167,14 @@ export function getTransformTargetLabel(target: TransformTarget): string {
|
|||||||
return `Whitebox Vertex (${getBrushVertexLabel(createBrushSnapshotFromTarget(target), target.vertexId)})`;
|
return `Whitebox Vertex (${getBrushVertexLabel(createBrushSnapshotFromTarget(target), target.vertexId)})`;
|
||||||
case "modelInstance":
|
case "modelInstance":
|
||||||
return getModelInstanceKindLabel();
|
return getModelInstanceKindLabel();
|
||||||
|
case "modelInstances":
|
||||||
|
return `${target.items.length} ${getModelInstanceKindLabel()}${target.items.length === 1 ? "" : "s"}`;
|
||||||
case "pathPoint":
|
case "pathPoint":
|
||||||
return "Path Point";
|
return "Path Point";
|
||||||
case "entity":
|
case "entity":
|
||||||
return getEntityKindLabel(target.entityKind);
|
return getEntityKindLabel(target.entityKind);
|
||||||
|
case "entities":
|
||||||
|
return `${target.items.length} Entit${target.items.length === 1 ? "y" : "ies"}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1177,6 +1183,7 @@ export function getSupportedTransformOperations(
|
|||||||
): TransformOperation[] {
|
): TransformOperation[] {
|
||||||
switch (target.kind) {
|
switch (target.kind) {
|
||||||
case "brush":
|
case "brush":
|
||||||
|
case "brushes":
|
||||||
case "brushFace":
|
case "brushFace":
|
||||||
case "brushEdge":
|
case "brushEdge":
|
||||||
return ["translate", "rotate", "scale"];
|
return ["translate", "rotate", "scale"];
|
||||||
@@ -1184,11 +1191,18 @@ export function getSupportedTransformOperations(
|
|||||||
case "pathPoint":
|
case "pathPoint":
|
||||||
return ["translate"];
|
return ["translate"];
|
||||||
case "modelInstance":
|
case "modelInstance":
|
||||||
|
case "modelInstances":
|
||||||
return ["translate", "rotate", "scale"];
|
return ["translate", "rotate", "scale"];
|
||||||
case "entity":
|
case "entity":
|
||||||
return target.initialRotation.kind === "none"
|
return target.initialRotation.kind === "none"
|
||||||
? ["translate"]
|
? ["translate"]
|
||||||
: ["translate", "rotate"];
|
: ["translate", "rotate"];
|
||||||
|
case "entities":
|
||||||
|
return target.items.every(
|
||||||
|
(item) => getSupportedTransformOperations(item).includes("rotate")
|
||||||
|
)
|
||||||
|
? ["translate", "rotate"]
|
||||||
|
: ["translate"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1205,10 +1219,13 @@ export function supportsTransformAxisConstraint(
|
|||||||
): boolean {
|
): boolean {
|
||||||
const brushTarget =
|
const brushTarget =
|
||||||
session.target.kind === "brush" ||
|
session.target.kind === "brush" ||
|
||||||
|
session.target.kind === "brushes" ||
|
||||||
session.target.kind === "brushFace" ||
|
session.target.kind === "brushFace" ||
|
||||||
session.target.kind === "brushEdge" ||
|
session.target.kind === "brushEdge" ||
|
||||||
session.target.kind === "brushVertex"
|
session.target.kind === "brushVertex"
|
||||||
? createBrushSnapshotFromTarget(session.target)
|
? session.target.kind === "brushes"
|
||||||
|
? createBrushSnapshotFromTarget(session.target.items[0])
|
||||||
|
: createBrushSnapshotFromTarget(session.target)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
switch (session.operation) {
|
switch (session.operation) {
|
||||||
@@ -1217,7 +1234,10 @@ export function supportsTransformAxisConstraint(
|
|||||||
case "scale":
|
case "scale":
|
||||||
if (
|
if (
|
||||||
session.target.kind === "modelInstance" ||
|
session.target.kind === "modelInstance" ||
|
||||||
|
session.target.kind === "modelInstances" ||
|
||||||
session.target.kind === "brush"
|
session.target.kind === "brush"
|
||||||
|
||
|
||||||
|
session.target.kind === "brushes"
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1256,6 +1276,16 @@ export function supportsTransformAxisConstraint(
|
|||||||
return axis === "y";
|
return axis === "y";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (session.target.kind === "entities") {
|
||||||
|
return session.target.items.every((item) =>
|
||||||
|
item.initialRotation.kind === "none"
|
||||||
|
? false
|
||||||
|
: item.initialRotation.kind === "yaw"
|
||||||
|
? axis === "y"
|
||||||
|
: true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (session.target.kind === "brushFace") {
|
if (session.target.kind === "brushFace") {
|
||||||
if (brushTarget === null) {
|
if (brushTarget === null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1294,10 +1324,16 @@ export function supportsLocalTransformAxisConstraint(
|
|||||||
|
|
||||||
switch (session.target.kind) {
|
switch (session.target.kind) {
|
||||||
case "brush":
|
case "brush":
|
||||||
|
case "brushes":
|
||||||
case "modelInstance":
|
case "modelInstance":
|
||||||
|
case "modelInstances":
|
||||||
return true;
|
return true;
|
||||||
case "entity":
|
case "entity":
|
||||||
return session.target.initialRotation.kind !== "none";
|
return session.target.initialRotation.kind !== "none";
|
||||||
|
case "entities":
|
||||||
|
return session.target.items.every(
|
||||||
|
(item) => item.initialRotation.kind !== "none"
|
||||||
|
);
|
||||||
case "brushFace":
|
case "brushFace":
|
||||||
case "brushEdge":
|
case "brushEdge":
|
||||||
case "brushVertex":
|
case "brushVertex":
|
||||||
|
|||||||
Reference in New Issue
Block a user