-
Notifications
You must be signed in to change notification settings - Fork 1
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
Added commands for object transforming (translate, rotate and scale) #441
base: main
Are you sure you want to change the base?
Conversation
Don't merge - testing against the engine |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #441 +/- ##
=======================================
Coverage ? 27.78%
=======================================
Files ? 35
Lines ? 1904
Branches ? 0
=======================================
Hits ? 529
Misses ? 1375
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ach transform type
modeling-cmds/src/def_enum.rs
Outdated
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] | ||
struct TransformBy<T> { | ||
/// The scale, or rotation, or translation. | ||
property: T, | ||
/// If true, overwrite the previous value with this. | ||
/// If false, the object will be scaled, or translated, or rotated, etc. | ||
set: bool, | ||
} | ||
|
||
///Set the transform of an object. | ||
#[derive( | ||
Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariantEmpty, | ||
)] | ||
pub struct SetObjectTransform | ||
{ | ||
///Id of the object whose transform is to be set | ||
pub object_id: Uuid, | ||
#[serde(default)] | ||
translate: Option<TransformBy<Point3d>>, | ||
#[serde(default)] | ||
rotate: Option<TransformBy<Point3d>>, | ||
#[serde(default)] | ||
scale: Option<TransformBy<Point3d>>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following is just a suggestion/idea. We can further reduce bandwidth by instead sending a list of transforms. Otherwise looks great!
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] | |
struct TransformBy<T> { | |
/// The scale, or rotation, or translation. | |
property: T, | |
/// If true, overwrite the previous value with this. | |
/// If false, the object will be scaled, or translated, or rotated, etc. | |
set: bool, | |
} | |
///Set the transform of an object. | |
#[derive( | |
Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariantEmpty, | |
)] | |
pub struct SetObjectTransform | |
{ | |
///Id of the object whose transform is to be set | |
pub object_id: Uuid, | |
#[serde(default)] | |
translate: Option<TransformBy<Point3d>>, | |
#[serde(default)] | |
rotate: Option<TransformBy<Point3d>>, | |
#[serde(default)] | |
scale: Option<TransformBy<Point3d>>, | |
} | |
enum TransformOperation { | |
Translate, | |
Rotate, | |
Scale | |
} | |
struct Transform<T> { | |
operation: TransformOperation, | |
value: T, | |
set: bool, | |
} | |
///Set the transform of an object. | |
#[derive( | |
Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariantEmpty, | |
)] | |
pub struct SetObjectTransform | |
{ | |
///Id of the object whose transform is to be set | |
pub object_id: Uuid, | |
transforms: Vec<Transform<Point3D>> | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this, but this allows you to send multiple transforms that overwrite each other, e.g. [(Translate, <0,0,0>), (Translate, <1,1,1>)]. So I think the current approach is better -- it limits you to sending at most one transform for a given property and the given project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be desirable from a programmer or mathematician point of view to compose transforms in various ways, ways I cannot imagine - for example [(Translate, <0,0,0>), (Translate, <1,1,1>)]
could be desirable if they are composing (have set: false
). Otherwise I agree with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are knocking on the door of a transform stack here. Which is where you specify a chain of transforms one after the other that get applied in that order. Typically comes along with the ability to push and pop transforms to a stack that lets you get pretty flexible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're now agreed that Transform endpoint should take a list of transforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So these transforms will get applied one by one if more than one is provided? Is it up to the user to handle the complexity of the list? E.g. if two translates are side by side that could have just been one aggregate transform.
Added Commands to transform objects: