Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Bug when casting FbxVector4 to double

Wh447
Explorer

Bug when casting FbxVector4 to double

Wh447
Explorer
Explorer
I discovered an issue with the FBX SDK (2020 but I believe earlier version as well) that affected Mac only.  On Xcode, the following code would fail even though it worked fine on Visual Studio.
 
double* trans = (double*)pNode->GetGeometricTranslation(ePivotSet);
double* rot = (double*)pNode->GetGeometricRotation(ePivotSet);
double* scale = (double*)pNode->GetGeometricScaling(ePivotSet);
 
It seemed that when casting the FbxVector4 value returned from these methods to double, the result would always be a vector with all components set to 1.0.
 
It seems the casting that was the problem.  If I did not cast it to double, the correct results were achieved.
0 Likes
Reply
205 Views
1 Reply
Reply (1)

bjornsundin02
Community Visitor
Community Visitor

Hi!

 

The GetGeometricTranslation function returns an object (not a reference). In this  case, the lifetime of the object ends directly after the statement that "casts" it to a double pointer. You get undefined behavior when you try to access objects that have gone out of scope. 

0 Likes