🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

C++ swizzle selector like GLSL?

Started by
19 comments, last by Juliean 2 years, 6 months ago

hplus0603 said:
@Juliean At that point, you need to construct the swizzlable instance temporarily, e g, you can't just take them as reference arguments or store them as members, so the amount of typing goes up. And in your case, you still have to make the function inline, intrusively, so there's really no gain on top of just making them return the real vec3.

The main gain is exactly what OP originally claimed he wanted:

vec3.yz() *= 2;

So there should be no need to store this as a field or pass as a reference anyways (the latter still being able to be optimized when inlined). This cannot be done when returning just a vec3 (the discussion about whether or not this in general is desirable is a different discussion entirely, as frob mentioned.

Another question though, what do you mean by having to make the function “intrusively” inline? I've never heard this term before and cannot find any explanation what it means.

This topic is closed to new replies.

Advertisement