I noticed that the vector math functions, such as .add and .mult set the value of the vector you input.
I’m doing somewhat complex operations so I need to use this functions many times without altering the value of the vector, is there any other way than making my own functions? And isn’t this the least convinient way of implementing this functions?
But the node shouldn’t change the input vector. If you look in the .hx source code you can see that the input vector is actually copied into a new object so that this doesn’t happen. A example file would indeed really help here, I can’t reproduce this as well.
Yes, thats the mutability of Iron vectors. But the VectorMath node calls v.setFrom(v1) (v1 is the input vector) which should actually prevent this by copying the vector.
Judging by the message, they write the code there, and not use logical nodes. And it is believed that the .add function should only return a new value.
Judging by the message, they write the code there, and not use logical nodes.
Oh of course, I was blinded a bit by the logic node screenshot above^^
A solution is to use myVec.clone().add(otherVec). Of course this is tedious to write but unfortunately that’s the current state (I hope that it will be improved when Iron finally moves to C). The functions for kha.math.FastVector3 on the other hand work like vectors are immutable, so if you don’t need to use Iron’s math classes, just switch to Kha’s.
Another solution would be to create a result vector and call addvecs():
var result = new Vec3();
result.addvecs(vec1, vec2);