Closed warrenelrod closed 9 months ago
Environment
I am inheriting the glm types into classes to extend functionality like this:
class Vec4(glm.vec4): def __init__(self, x, y, z, w): super().__init__(x, y, z, w) def ceil(self): self.xyzw = glm.ceil(self).xyzw return self def normalize(self): self.xyzw = glm.normalize(self).xyzw return self v = Vec4(1.2, 2.1, 3.9, 4.5) print(v) v.ceil().normalize() print(v) -> Vec4( 1.2, 2.1, 3.9, 4.5 ) -> Vec4( 0.272166, 0.408248, 0.544331, 0.680414 )
The problem I run into is this:
print(glm.vec1().abs) -> AttributeError: 'glm.vec1' object has no attribute 'abs' print(glm.vec2().abs) -> AttributeError: 'glm.vec2' object has no attribute 'abs' print(glm.vec3().abs) -> AttributeError: 'glm.vec3' object has no attribute 'abs' print(glm.vec4().abs) -> vec3( 0, 0, 0 )
Calling glm.vec4() seems to return an object carrying some dirty laundry.
Note: "abs" is not an attribute of glm.vec1, 2, 3... or vec4
After reading into the the glm cpp code i realize that it is from swizzling
Environment
I am inheriting the glm types into classes to extend functionality like this:
The problem I run into is this:
Calling glm.vec4() seems to return an object carrying some dirty laundry.
Note: "abs" is not an attribute of glm.vec1, 2, 3... or vec4