I think I've encountered a bug. I'm not really sure how to explain it because I don't fully understand it myself. I noticed that one of my scripts stopped behaving like it should. It's a simple script (executed every frame on a persistent object) for simulating a ball and the object no longer rolls properly. I tracked it down to a line of angelscript code that deals with its rotation property.
engine->RegisterObjectMethod("Object", "void set_rotation(float)", asMETHOD(ASObject, SetRotation), asCALL_THISCALL);
engine->RegisterObjectMethod("Object", "float get_rotation() const", asMETHOD(ASObject, GetRotation), asCALL_THISCALL);
Consider these Angelscript code snippets:
float elapsed = 1.0f; // just some float
obj.rotation = obj.rotation + elapsed * 1.0f;
float elapsed = 1.0f;
float temp = obj.rotation + elapsed * 1.0f;
obj.rotation = obj.rotation + elapsed * 1.0f;
The first snippet executes as you would expect. obj.rotation evaluates to 1, the next iteration it evalutates to 2, 3, etc. i.e. the ball is rolling. In the second snippet obj.rotation always evaluates to 2 for each and every iteration. When I debug it my GetRotation method returns 2.0f and the value that is passed to SetRotation from Angelscript is still 2.0f. 2 + 1 * 1 should be 3 right? The weird part is that if I change this code just slightly it works as expected again:
float elapsed = 1.0f;
float temp = obj.rotation + elapsed;
obj.rotation = obj.rotation + elapsed * 1.0f;
The code above was written to reproduce the bug. It's much harder for me to get rid of it in my actual script, which looks something like this:
// ... Ball simulation above ...
self.rotation = self.rotation + elapsed * FuncReturningAFloat(...);
This must seem pretty nonsensical but there's most likely some bug in there somewhere.