Why is there no operator overload in SceneKit?

It seems obvious to me to add operator overloads for types like SCNMatrix4 and SCNVector3 , but Apple seems to have chosen to use static global functions (like SCNMatrix4Mult ). Although operators, such as matrix multiplication and adding vectors, are trivial to add, I'm interested in:

Implementation Example:

 func * (left: SCNMatrix4, right: SCNMatrix4) -> SCNMatrix4 { return SCNMatrix4Mult(left, right) } func + (left: SCNVector3, right: SCNVector3) -> SCNVector3 { return SCNVector3Make(left.x + right.x, left.y + right.y, left.z + right.z) } 
+2
source share
1 answer

These functions are SceneKit utilities written for Objective-C that are simply exported to Swift as-is. I agree that it would be nice to have them as operators instead of global functions, but it seems like the related code has not yet been written.

Please note: if you want your code to be more expressive and efficient, you can easily use the new SIMD-based SCNNode on SCNNode . You can find an example of this related SO question .

+1
source

Source: https://habr.com/ru/post/989084/


All Articles