Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Version 2.8 (160)

2»

Comments

  • dave1707dave1707 Mod
    Posts: 8,566

    @Simeon I’ve used number * vec a lot, but not the vec * vec. I thought that vec4(2,4,6,8) * vec4(2,3,4,5) would have resulted in vec4(4,12,24,,40). I’ve never tried doing that before and was surprised when it didn’t work.

    Have you looked into why Codea crashes when number * vec get large values and why the values are different for the different vec sizes. Maybe instead of crashing, it could return inf or nil values.

    The memory problem was a surprise to me. I thought there was an auto collectgarbage when needed. In my above code, if I just let the code run, memory would increase and there would be a collectgarbage to reduce memory. That would cycle every so many seconds. One thing I noticed with the code was if I created the table and then reinitialized it, the memory wasn’t reduced. If I would then let Codea increase it’s memory with the table memory, a collectgarbage would run and reduce memory but not clean up the memory from the initialized table. It’s like the auto collectgarbage would clear the normal memory increase but not the table memory. A forced collectgarbage would reduce the table memory. There must be two different collectgarbage routines.

  • dave1707dave1707 Mod
    Posts: 8,566

    @Simeon Why does print( vec4() ) show (0.000000, 0.000000, 0.000000, 1.000000) and not all zeroes. Or that print( vec4(1,2,3) ) prints a 1 for the missing 4 position.

  • Posts: 1,807

    @dave1707 - is that due to vec4() ‘s association with the alpha value in colour representation defaulting to 255 - which I think is 1.000000 in OpenGL.

  • dave1707dave1707 Mod
    Posts: 8,566

    @Bri_G I don't know. I just thought it was strange that the other values show 0 but the forth shows 1.

  • SimeonSimeon Admin Mod
    Posts: 5,405

    @dave1707 @bri_G the default w component of a vec4 is 1.0 because typically when you use vectors to represent 3D points in space, and want to transform them with 4x4 matrices, you set the w value to 1.0

    https://gamedev.stackexchange.com/questions/28249/calculate-new-vertex-position-given-a-transform-matrix

  • dave1707dave1707 Mod
    Posts: 8,566

    @Simeon Thanks for the link. I didn't know if it was a bug or supposed to be like that.

Sign In or Register to comment.