Skip to content

Commit

Permalink
move scenelight implementation into the right source file
Browse files Browse the repository at this point in the history
  • Loading branch information
toloudis committed Jan 16, 2024
1 parent bca0d56 commit 1634fca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 0 additions & 26 deletions renderlib/AppScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,29 +150,3 @@ Scene::getFirst4EnabledChannels(uint32_t& c0, uint32_t& c1, uint32_t& c2, uint32
c2 = ch[2];
c3 = ch[3];
}

void
SceneLight::updateTransform()
{
// update from transform position and rotation.

// calculate the new direction for the light to point in
glm::vec3 normdir = m_transform.m_rotation * glm::vec3(0, 0, 1);

// compute the phi and theta for the new direction
// because they will be used in future light updates
float phi, theta;
Light::cartesianToSpherical(normdir, phi, theta);
m_light->m_Phi = phi;
m_light->m_Theta = theta;

// get m_P in world space:
m_light->m_P = m_light->m_Distance * normdir + m_light->m_Target;

m_light->updateBasisFrame();

// this lets the GUI have a chance to update in an abstract way
for (auto it = m_observers.begin(); it != m_observers.end(); ++it) {
(*it)(*m_light);
}
}
26 changes: 26 additions & 0 deletions renderlib/Light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,29 @@ Light::cartesianToSpherical(glm::vec3 v, float& phi, float& theta)
phi = acosf(v.y);
theta = atan2f(v.x, v.z);
}

void
SceneLight::updateTransform()
{
// update from transform position and rotation.

// calculate the new direction for the light to point in
glm::vec3 normdir = m_transform.m_rotation * glm::vec3(0, 0, 1);

// compute the phi and theta for the new direction
// because they will be used in future light updates
float phi, theta;
Light::cartesianToSpherical(normdir, phi, theta);
m_light->m_Phi = phi;
m_light->m_Theta = theta;

// get m_P in world space:
m_light->m_P = m_light->m_Distance * normdir + m_light->m_Target;

m_light->updateBasisFrame();

// this lets the GUI have a chance to update in an abstract way
for (auto it = m_observers.begin(); it != m_observers.end(); ++it) {
(*it)(*m_light);
}
}

0 comments on commit 1634fca

Please sign in to comment.