Skip to content

Commit

Permalink
Update RenderHook
Browse files Browse the repository at this point in the history
  • Loading branch information
doyaGu committed Jul 4, 2024
1 parent 34c8f0a commit 27b64c5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/RenderHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ CKERROR CKRenderedScene::Draw(CK_RENDER_FLAGS Flags) {
rootEntity->m_WorldMatrix = camera->m_WorldMatrix;
rootEntity->WorldMatrixChanged(FALSE, TRUE);
VxVector vec;
camera->InverseTransform(&vec, rootEntity->m_WorldMatrix[3]);
camera->InverseTransform(&vec, &rootEntity->m_WorldMatrix[3]);
auto z = dev->m_NearPlane / fabsf(vec.z);
float right = (camera->m_LocalBoundingBox.Max.x - vec.x) * z;
float left = (camera->m_LocalBoundingBox.Min.x - vec.x) * z;
Expand Down Expand Up @@ -353,17 +353,21 @@ void CKRenderedScene::PrepareCameras(CK_RENDER_FLAGS Flags) {
CKCamera *camera = *it;
if (camera && camera->GetClassID() == CKCID_TARGETCAMERA) {
auto *target = camera->GetTarget();
if (target)
camera->LookAt(VxVector(0.0f, 0.0f, 0.0f), target);
if (target) {
VxVector o(0.0f);
camera->LookAt(&o, target);
}
}
}

for (auto it = m_Lights.Begin(); it != m_Lights.End(); ++it) {
CKLight *light = *it;
if (light && light->GetClassID() == CKCID_TARGETLIGHT) {
auto *target = light->GetTarget();
if (target)
light->LookAt(VxVector(0.0f, 0.0f, 0.0f), target);
if (target) {
VxVector o(0.0f);
light->LookAt(&o, target);
}
}
}

Expand Down

0 comments on commit 27b64c5

Please sign in to comment.