feat: accept readonly inputs across the package - #53
Draft
RodrigoHamuy wants to merge 31 commits into
Draft
Conversation
Add RVec2, a readonly Vec2, and use it for every vec2 parameter that is only read from. Output parameters stay mutable Vec2 so the receiving vector can still be written to. Mutable vectors remain assignable to RVec2, so existing callers are unaffected. Callers holding a readonly vector can now pass it directly instead of copying or casting. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RVec3, a readonly Vec3, and use it for every vec3 parameter that is only read from. Output parameters stay mutable Vec3 so the receiving vector can still be written to. Mutable vectors remain assignable to RVec3, so existing callers are unaffected. Callers holding a readonly vector can now pass it directly instead of copying or casting. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RVec4, a readonly Vec4, and use it for every vec4 parameter that is only read from. Output parameters stay mutable Vec4 so the receiving vector can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RQuat, a readonly Quat, and use it for every quaternion parameter that is only read from. Read-only vec3 parameters take RVec3 as well. Output parameters stay mutable so the receiving value can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RQuat2, a readonly Quat2, and use it for every dual quaternion parameter that is only read from. Read-only quat and vec3 parameters take RQuat and RVec3 as well. Output parameters stay mutable so the receiving value can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RMat2, a readonly Mat2, and use it for every matrix parameter that is only read from. Read-only vec2 parameters take RVec2 as well. Output parameters stay mutable so the receiving matrix can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RMat2d, a readonly Mat2d, and use it for every matrix parameter that is only read from. Read-only vec2 parameters take RVec2 as well. Output parameters stay mutable so the receiving matrix can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RMat3, a readonly Mat3, and use it for every matrix parameter that is only read from. Read-only mat2d, quat and vec2 parameters take their readonly aliases as well. Output parameters stay mutable so the receiving matrix can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RMat4, a readonly Mat4, and use it for every matrix parameter that is only read from. Read-only quat, quat2 and vec3 parameters take their readonly aliases as well. Output parameters stay mutable so the receiving value can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add REuler, a readonly Euler, and use it for every euler parameter that is only read from, in euler and in quat.fromEuler. Read-only mat4 and quat parameters take their readonly aliases as well. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RSpherical, a readonly Spherical, and use it for every spherical parameter that is only read from. Read-only vec2 and vec3 parameters take their readonly aliases as well. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RPolar, a readonly Polar, and use it for every polar parameter that is only read from. Read-only vec2 parameters take RVec2 as well. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RColor, a readonly Color, and use it for every color parameter that is only read from, in color, colorspace and hsl. Read-only sRGB triples become readonly tuples too. Output parameters stay mutable so the receiving color can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RHSL, a readonly HSL, and use it for every hsl parameter that is only read from. Output parameters stay mutable so the receiving color can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RBox2, a readonly Box2, and use it for every box parameter that is only read from. Read-only vec2 parameters take RVec2 as well. Output parameters stay mutable so the receiving box can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RBox3, a readonly Box3, and use it for every box parameter that is only read from. Read-only vec3 and mat4 parameters take their readonly aliases as well. Output parameters stay mutable so the receiving box can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RSphere, a sphere whose center and radius are both readonly, and use it for every sphere parameter that is only read from. Readonly<Sphere> alone would still allow writes through the center vector, so the fields are spelled out. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RCircle, a circle whose center and radius are both readonly, and use it for the read-only circle parameter of box2.intersectsCircle. The fields are spelled out because Readonly<Circle> would still allow writes through the center vector. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RPlane3, a plane whose normal and constant are both readonly, and use it for every plane parameter that is only read from. Read-only vec3, mat4 and sphere parameters take their readonly aliases as well. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add ROBB3, an oriented box whose center, half extents and rotation are all readonly, and use it for every obb parameter that is only read from. Read-only vec3, mat3, mat4, quat and box3 parameters take their readonly aliases as well. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RFrustum and RFrustumCorners, whose planes and vectors are readonly all the way down, and use RFrustum for every frustum parameter that is only read from. Read-only mat4, sphere, box3 and vec3 parameters take their readonly aliases as well. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Use RVec2 for every vector parameter that is only read from. Output parameters stay mutable Vec2 so the receiving vector can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Use RVec2 for every vertex and point parameter that is only read from. Output parameters stay mutable so the receiving vector or box can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Use RVec3 for every vertex parameter that is only read from. Output parameters stay mutable so the receiving vector or box can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Use RVec3 for the ray and triangle parameters and RBox3 for the tested box. IntersectsTriangleResult is written to, so it stays mutable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Vertex buffers that are only read from become readonly number[], and read-only point and segment parameters take RVec2. The reverse output buffer and the out vector and box parameters stay mutable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Vertex and point buffers that are only read from become readonly number[], and circumcircle takes RVec2 points. Accumulators and out parameters stay mutable so results can still be written to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Spring targets and the initial value passed to create are only read from, so they take RVec2, RVec3 and RVec4. The spring state itself is mutated each frame and stays mutable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Targets, base locations, bone endpoints, directions and constraint axes are only read from, so they take RVec2 and RVec3. The chain, bone and joint structures are solved in place and stay mutable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
choice only reads the array it picks from, so it takes readonly T[]. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The modules converted before their dependencies had readonly aliases still took mutable ones. Transform functions now take RMat2, RMat2d, RMat3, RMat4 and RQuat, mat3 and quat2 take RMat4, and box3 takes RSphere and RPlane3. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continuation of:
Types added
RVec2RVec3RVec4RQuatRQuat2RMat2RMat2dRMat3RMat4REulerRSphericalRPolarRColorRHSLRBox2RBox3RSphereRCircleRPlane3ROBB3RFrustumRFrustumCorners