Jump to content

Operators on Vec2 and 4 missing?


thehankinator
 Share

Recommended Posts

I am not able to divide a Vec2 or Vec4 but Vec3 works fine. Seems like this should work, am I wrong?

local Case1 = Vec2(164, 0) / 255 --Doesn't work
local Case2 = Vec3(164, 0, 0) / 255 --Works
local Case3 = Vec4(164, 0, 0, 255) / 255 --Doesn't work

Error message for Case1 and 3 is:

Attempt to perform operation on an invalid operand

Link to comment
Share on other sites

Appears they are missing looking at the class members available for Vec3 versus Vec2 & Vec4:

Vec3			Vec4			Vec2
.add			.add			missing members
.div			.eq
.eq			.mul
.mul
.sub
  

Don't know for sure if related but it appears to be. The '.div' member is missing for Vec4, but since the '.mul' member exists you can make Case3 work by multiplying the Vec4() with (1/255).

 

Would be nice if the other two vector classes were given the same abilities.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

16 hours ago, thehankinator said:

It'd be handy if Vec4 had a division operator for converting colors defined in 0-255 to 0-1

Just curious, but what do you have that is defining colors in 0-255? The editor does when you use the color picker but those values are converted to the 0-1 scale. Everything in LE now except for the color picker itself (which I suspect is due to the OS), specifically uses 0-1, so what are you doing/using that would require that specifically where you couldn't just make a simple function to handle it?

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

10 minutes ago, macklebee said:

Just curious, but what do you have that is defining colors in 0-255? The editor does when you use the color picker but those values are converted to the 0-1 scale. Everything in LE now except for the color picker itself (which I suspect is due to the OS), specifically uses 0-1, so what are you doing/using that would require that specifically where you couldn't just make a simple function to handle it?

I am creating emitters in code. It's convenient for me to define them in the editor then convert them to code. I don't have to do it this way but a division operator for a Vec4 isn't an uncommon thing in a vector library. Nothing I am doing requires this operator, I've already got a workaround. 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...