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

Allow event-based objects to define a rotation center point #4910

Merged
merged 5 commits into from
Feb 20, 2023
Merged

Conversation

D8H
Copy link
Collaborator

@D8H D8H commented Feb 8, 2023

Changes

  • Remove the ability to move camera inside a custom object.
  • Use affine transformation to evaluate child hitboxes.
  • Fix the transformation of the custom object renderer of the scene editor.

Demo

@D8H
Copy link
Collaborator Author

D8H commented Feb 8, 2023

I wonder if I should add private expressions to access custom object internal bounds as events can no longer rely on camera bounds.

Comment on lines +36 to +38
_localTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();
_localInverseTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();
_isLocalTransformationDirty: boolean = true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will take more memory but the code is easier to maintain and maybe faster because an affine transformation is 8 arithmetical operations versus something like 25 for the hand crafted transformation.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's fine and fair to have these. Custom objects are not designed to be super lightweight objects working as particles for example.

Comment on lines 69 to 74
this._pixiContainer.position.x =
this._object.getDrawableX() +
this._object.getX() +
this._pixiContainer.pivot.x * Math.abs(this._object._scaleX);
this._pixiContainer.position.y =
this._object.getDrawableY() +
this._object.getY() +
this._pixiContainer.pivot.y * Math.abs(this._object._scaleY);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was compensating the side effects of the camera bug.

The internal camera of custom objects was trying to stay at the center of the children. This way the transformation has no effect and children were not shifted. This system has been removed to avoid any side effects as it doesn't really make sense.

Comment on lines -89 to +93
/** @type gdjs.Layer */
const theLayer: gdjs.Layer = this._layers.items[name];
const theLayer: gdjs.RuntimeLayer = this._layers.items[name];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is /** @type gdjs.Layer */ useful in some way or is it a remanent comment from a long forgotten JS past?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remanent from a long forgotten JS past 👻

@D8H D8H marked this pull request as ready for review February 8, 2023 17:27
@D8H D8H requested a review from 4ian as a code owner February 8, 2023 17:27
@@ -363,6 +333,9 @@ namespace gdjs {
* @returns the center X from the local origin (0;0).
*/
getUnscaledCenterX(): float {
if (this._customCenter) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a bug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a feature I forgot to add. Though, we had already done it for the shape painter version of the slider.

*
* It adapts the layers camera positions.
*/
onObjectUnscaledCenterChanged(oldOriginX: float, oldOriginY: float): void {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Why don't we need this anymore?

Copy link
Collaborator Author

@D8H D8H Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The internal camera of custom objects was trying to stay at the center of the children (a bit like camera stays on the upper left corner of the scene). This way the transformation has no effect and children were not shifted. This system has been removed to avoid any side effects as it doesn't really make sense.

i18n._(
'Change the center of rotation of an object relatively to the object origin.'
),
i18n._('Change the center of rotation of _PARAM0_: _PARAM1_; _PARAM2_'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the center of rotation of X to Y;Z (relative to the object origin)

Copy link
Collaborator Author

@D8H D8H Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind either but "Change" is used in most actions, the ones related to positions for instance. Should it be consistent?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, it should be Change the center of rotation of X (relative to the object origin): set to Y;Z

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(otherwise this is not a valid sentence, and while we don't see it because we're used to it, any new user will notice it and will see it as a bad quality software)

@D8H D8H marked this pull request as ready for review February 11, 2023 15:34
@@ -589,8 +589,9 @@ void ExporterHelper::AddLibsInclude(bool pixiRenderers,
InsertUnique(includesFiles, "runtimescene.js");
InsertUnique(includesFiles, "scenestack.js");
InsertUnique(includesFiles, "force.js");
InsertUnique(includesFiles, "RuntimeLayer.js");
InsertUnique(includesFiles, "layer.js");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be sure I understand: ideally, from the beginning, gdjs.Layer would have been gdjs.RuntimeSceneLayer if it was perfectly named, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly

@4ian
Copy link
Owner

4ian commented Feb 20, 2023

Storybook is failing because of a Node upgrade, feel free to ignore.

@D8H
Copy link
Collaborator Author

D8H commented Feb 20, 2023

Storybook is failing because of a Node upgrade, feel free to ignore.

Ok, and the failed test is about the firebase extension.

@D8H D8H merged commit 257ba78 into master Feb 20, 2023
@D8H D8H deleted the ebo-center branch February 20, 2023 10:55
@D8H D8H changed the title Allow event-based object to define a rotation center point Allow event-based objects to define a rotation center point Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants