-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Nodes: Allow JS-like assigns, implement AssignNode #26795
Conversation
Signed-off-by: Levi Pesin <[email protected]>
Signed-off-by: Levi Pesin <[email protected]>
Signed-off-by: Levi Pesin <[email protected]>
Signed-off-by: Levi Pesin <[email protected]>
Signed-off-by: Levi Pesin <[email protected]>
Signed-off-by: Levi Pesin <[email protected]>
Signed-off-by: Levi Pesin <[email protected]>
Signed-off-by: Levi Pesin <[email protected]>
Signed-off-by: Levi Pesin <[email protected]>
The code below cannot return the same vector, see #26493 (comment), #26493 (comment) vec = vec.xy.assign( 1 ); -- The code below is good! variable.xy = vec2( 1, 2 ); Is it possible to you simplify this PR to support just this? |
Would this be compatible with |
It can be confusing for the user to try something like this and it doesn't work properly: const variable = temp( ... );
stack.if( bool, ( stack ) => {
variable.x = 123;
} ); |
Yeah, I understand now that it looks quite confusing... Maybe we could say that the "main" approach is to do
I think the problem here is in |
I don't think we should support this syntax |
I don't really see how to support the "bonus" syntax without supporting this one... |
I'm afraid with the latest changes to VarNode.assign() the "bonus" syntax can no longer work... The |
There is an approach that could work, although we would have to find a good way to do it. This would be having a global stack reference, like |
Signed-off-by: Levi Pesin <[email protected]>
@@ -59,8 +59,11 @@ class Background extends DataMap { | |||
getSamplerLevelNode: () => backgroundBlurriness | |||
} ).mul( backgroundIntensity ); | |||
|
|||
let viewProj = modelViewProjection(); | |||
viewProj = viewProj.setZ( viewProj.w ); | |||
const viewProj = tslFn( () => { |
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.
This wouldn't work normally, because currentStack
is null when this is ran -- so I've wrapped it in a some kind of "Node IIFE".
SplitNode.assign()
and ArrayElementNode.assign()
@sunag This PR should work now. It has also became much simpler with the latest changes and also now non-VarNodes should be also supported. (There is a one minor issue with possibility of (AssignNode can be moved to its own PR if needed) Also, not sure whether we need |
Thanks! |
I think |
If |
It looks like this PR broke |
Don't worry about it, I'll publish a PR to review, Great work! |
I think JS doesn't allow overriding such operators yet |
Alternative to #26785Description
ImplementsSplitNode.assign()
andArrayElementNode.assign()
, also adds a separate class for AssignNode.Same cases of use are supported:Following use cases are also supported:The following use cases for VarNodes are supported as a bonus:Caching issueSomething is quite wrong with its caching in the case of Background:But it also was before:So I just fixed it in Background manually by adding.temp()
-- but if using the "bonus" use case the caching issue still appears.Adds support for JS-like assigns: