refactored viewproj matrix calcs a bit
This commit is contained in:
@@ -41,7 +41,6 @@ private:
|
|||||||
packet2_t *currPacket;
|
packet2_t *currPacket;
|
||||||
u8 context;
|
u8 context;
|
||||||
packet2_t *matricesPacket __attribute__((aligned(64)));
|
packet2_t *matricesPacket __attribute__((aligned(64)));
|
||||||
MATRIX localWorld, localScreen;
|
|
||||||
VECTOR position, rotation;
|
VECTOR position, rotation;
|
||||||
u32 vertCount;
|
u32 vertCount;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ void VifSender::uploadMicroProgram()
|
|||||||
|
|
||||||
void VifSender::sendMatrices(const RenderData &t_renderData, const Vector3 &t_position, const Vector3 &t_rotation)
|
void VifSender::sendMatrices(const RenderData &t_renderData, const Vector3 &t_position, const Vector3 &t_rotation)
|
||||||
{
|
{
|
||||||
vec3ToNative(position, t_position, 1.0F);
|
Matrix viewProj = Matrix();
|
||||||
vec3ToNative(rotation, t_rotation, 1.0F);
|
viewProj.rotation(t_rotation); // model matrix
|
||||||
create_local_world(localWorld, position, rotation);
|
viewProj.translate(t_position); // model matrix
|
||||||
create_local_screen(localScreen, localWorld, t_renderData.worldView->data, t_renderData.perspective->data);
|
viewProj *= *t_renderData.worldView * *t_renderData.perspective; // viewproj = model * (view * projection)
|
||||||
packet2_reset(matricesPacket, false);
|
packet2_reset(matricesPacket, false);
|
||||||
packet2_utils_vu_add_unpack_data(matricesPacket, 0, &localScreen, 8, 0);
|
packet2_utils_vu_add_unpack_data(matricesPacket, 0, &viewProj.data, 8, 0);
|
||||||
packet2_utils_vu_add_end_tag(matricesPacket);
|
packet2_utils_vu_add_end_tag(matricesPacket);
|
||||||
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
||||||
dma_channel_send_packet2(matricesPacket, DMA_CHANNEL_VIF1, 1);
|
dma_channel_send_packet2(matricesPacket, DMA_CHANNEL_VIF1, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user