Matrix.copyFrom stopped to work starting alpha-48

Well I guess I misread initially. The current behavior is actually correct :slight_smile:

I do not understand why you need to ++ on the updateFlag afterwards as the matrix flag must have changed after the copy (to match the source one)

If _markAsUpdated() is called after calling toArray(entityMatrix.m) to directly alter the values, then the flag would be properly changed. I think making that public could be a good solution. :slight_smile:

1 Like

Unless you took for granted that the updateFlag was unique?

I can make it public, no problem at all. But @bghgary convinced me we should not call it automatically as it is expected to have the same flag as the contents are the same

It should only be called automatically by the methods of Matrix that cause the m array to change I think, that way you can test the flags to see if the m values have changed?

The problem is this line. This will update the matrix array directly without updating the updateFlag.

1 Like

not this one as we want to keep the if (a.updateFlag === b.updateFlag) then we know they are the same

make the marASUpdated public by deltakosh · Pull Request #11885 · BabylonJS/Babylon.js (github.com)

3 Likes

That’s why I’m saying to change it whenever the matrix values are changed…

Yep, exactly, and I said that a few times as well. I’m gonna bow out and let you guys figure this one out, we’re kinda talking around each other in circles I think LOL. :slight_smile:

1 Like

Is this user code?

Lol yes

So to summarize: we are going to expose the markAsUpdated function

When you call toArray you will have to manually call the markAsUpdated as we cannot do it from the toArray function

3 Likes
 entity.worldMatrix.toArray(entityMatrix.m)

entity.worldMatrix.toArray is a method in your code, not in Babylon. So it’s your responsibility to update the updateFlag of the entityMatrix because you know you are going to update the values. If possible, I think you should pass entityMatrix instead of entityMatrix.m to toArray and let your toArray method update the updateFlag (thanks to the new public markAsUpdated method).

@Deltakosh it’s still a breaking change, as outlined by this thread, even if I think it can be labeled as a bug in 4.2 (the updateFlag was updated too often, even when the matrix values did not change). Maybe a line should be dropped in the Breaking change section about this?

5 Likes

Totally. @bghgary will take care of mentioning it

1 Like

What did I start? :speak_no_evil:

1 Like

Thank you guys! :vulcan_salute:

3 Likes

Add note to breaking changes about updating matrix array directly by bghgary · Pull Request #11886 · BabylonJS/Babylon.js (github.com)

5 Likes