[scene] Provide direct access to the world matrix

Holding onto the pointer is not a good idea, and it is read-only as
direct manipulation of the world matrix is not supported. However, this
is useful for passing the matrix to the GPU.
This commit is contained in:
Bill Currie 2021-12-17 16:42:31 +09:00
parent 869cc4050c
commit 8b1eec08cf
2 changed files with 9 additions and 0 deletions

View file

@ -61,6 +61,8 @@ uint32_t Transform_GetTag (const transform_t *transform) __attribute__((pure));
void Transform_GetLocalMatrix (const transform_t *transform, mat4f_t mat); void Transform_GetLocalMatrix (const transform_t *transform, mat4f_t mat);
void Transform_GetLocalInverse (const transform_t *transform, mat4f_t mat); void Transform_GetLocalInverse (const transform_t *transform, mat4f_t mat);
void Transform_GetWorldMatrix (const transform_t *transform, mat4f_t mat); void Transform_GetWorldMatrix (const transform_t *transform, mat4f_t mat);
// XXX the pointer may be invalidated by hierarchy updates
const vec4f_t *Transform_GetWorldMatrixPtr (const transform_t *transform) __attribute__((pure));
void Transform_GetWorldInverse (const transform_t *transform, mat4f_t mat); void Transform_GetWorldInverse (const transform_t *transform, mat4f_t mat);
vec4f_t Transform_GetLocalPosition (const transform_t *transform) __attribute__((pure)); vec4f_t Transform_GetLocalPosition (const transform_t *transform) __attribute__((pure));
void Transform_SetLocalPosition (transform_t *transform, vec4f_t position); void Transform_SetLocalPosition (transform_t *transform, vec4f_t position);

View file

@ -183,6 +183,13 @@ Transform_GetWorldMatrix (const transform_t *transform, mat4f_t mat)
memcpy (mat, h->worldMatrix.a[transform->index], sizeof (mat4f_t)); memcpy (mat, h->worldMatrix.a[transform->index], sizeof (mat4f_t));
} }
const vec4f_t *
Transform_GetWorldMatrixPtr (const transform_t *transform)
{
hierarchy_t *h = transform->hierarchy;
return h->worldMatrix.a[transform->index];
}
void void
Transform_GetWorldInverse (const transform_t *transform, mat4f_t mat) Transform_GetWorldInverse (const transform_t *transform, mat4f_t mat)
{ {