From be03011f21865dae534bc0048ecc535ab7b46687 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 11 May 2021 10:31:03 +0200 Subject: [PATCH] rplight: PSSMCameraRig::update() should accept cam node directly Previously it would always use the first child of the given node (presumably expecting that `base.camera` is passed in), which is inconvenient when dealing with multiple cameras. --- contrib/src/rplight/pssmCameraRig.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/src/rplight/pssmCameraRig.cxx b/contrib/src/rplight/pssmCameraRig.cxx index 8b8c22fd20..f9744e2129 100644 --- a/contrib/src/rplight/pssmCameraRig.cxx +++ b/contrib/src/rplight/pssmCameraRig.cxx @@ -369,8 +369,16 @@ void PSSMCameraRig::update(NodePath cam_node, const LVecBase3 &light_vector) { LMatrix4 transform = cam_node.get_transform()->get_mat(); // Get Camera and Lens pointers - Camera* cam = DCAST(Camera, cam_node.get_child(0).node()); - nassertv(cam != nullptr); + Camera *cam; + PandaNode *node = cam_node.node(); + if (node->is_of_type(Camera::get_class_type())) { + cam = (Camera *)node; + } + else { + // Perhaps we passed in something like base.camera ? + cam = DCAST(Camera, cam_node.get_child(0).node()); + nassertv(cam != nullptr); + } Lens* lens = cam->get_lens(); // Extract near and far points: