haxiomic / vector-math

Shader-math in haxe: library for GLSL vector operations, complete with swizzles and all
MIT License
39 stars 7 forks source link

Should vector.xy *= 0.5 change vector? #7

Closed haxiomic closed 1 year ago

haxiomic commented 3 years ago

For example

    color.xy = vec2(1.);
    color.xy *= 0.5;

currently color will not change, because a new vector is created with the .xy, however in glsl it does change

There's some ambiguity on how to interpret this in haxe; Is it this (ideal & glsl spec behavior)?

color.xy = color.xy * 0.5; // (modifies color)

Or this?

var v = color.xy;
v *= 0.5;

(current haxe behavior because of *= overload)

haxiomic commented 3 years ago

can be fixed by reverting to generated swizzle fields and removing the assignment overloads

haxiomic commented 3 years ago

fixed in https://github.com/haxiomic/vector-math/tree/fix-swizzle-assign-op but with the cost of allocations for these operations can the inlining be improved in the compiler?

haxiomic commented 3 years ago

get a compiler failure when removing *= to fix this issue: https://github.com/HaxeFoundation/haxe/issues/10150