GOOENGINE: Add geometry nodes active camera override

Adds a second camera property to the scene that is used only by geometry nodes in the Active Camera node. Necessary for our new environment file pipeline
This commit is contained in:
2025-11-30 15:33:25 -06:00
parent e0b0cc6012
commit dded3c1ce7
10 changed files with 42 additions and 3 deletions
@@ -49,6 +49,7 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel):
scene = context.scene
layout.prop(scene, "camera")
layout.prop(scene, "gn_camera_override")
layout.prop(scene, "background_set")
layout.prop(scene, "active_clip", text="Active Clip")
@@ -854,6 +854,7 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, scene->camera, IDWALK_CB_NOP);
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, scene->gn_camera_override, IDWALK_CB_NOP);
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, scene->world, IDWALK_CB_USER);
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, scene->set, IDWALK_CB_NEVER_SELF);
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, scene->clip, IDWALK_CB_USER);
@@ -1989,6 +1989,10 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
/* TODO(sergey): Use visibility of owner of the node tree. */
build_object(-1, node_scene->camera, DEG_ID_LINKED_INDIRECTLY, true);
}
if (node_scene->gn_camera_override != nullptr) {
/* TODO(sergey): Use visibility of owner of the node tree. */
build_object(-1, node_scene->gn_camera_override, DEG_ID_LINKED_INDIRECTLY, true);
}
}
else if (id_type == ID_TXT) {
/* Ignore script nodes. */
@@ -39,6 +39,9 @@ void DepsgraphNodeBuilder::build_scene_camera(Scene *scene)
if (scene->camera != nullptr) {
build_object(-1, scene->camera, DEG_ID_LINKED_INDIRECTLY, true);
}
if (scene->gn_camera_override != nullptr) {
build_object(-1, scene->gn_camera_override, DEG_ID_LINKED_INDIRECTLY, true);
}
LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) {
if (!ELEM(marker->camera, nullptr, scene->camera)) {
build_object(-1, marker->camera, DEG_ID_LINKED_INDIRECTLY, true);
@@ -3056,6 +3056,9 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
if (node_scene->camera != nullptr) {
build_object(node_scene->camera);
}
if (node_scene->gn_camera_override != nullptr) {
build_object(node_scene->gn_camera_override);
}
}
else if (id_type == ID_TXT) {
/* Ignore script nodes. */
@@ -30,6 +30,9 @@ void DepsgraphRelationBuilder::build_scene_render(Scene *scene, ViewLayer *view_
if (scene->camera != nullptr) {
build_object(scene->camera);
}
if (scene->gn_camera_override != nullptr) {
build_object(scene->gn_camera_override);
}
}
void DepsgraphRelationBuilder::build_scene_camera(Scene *scene)
@@ -37,6 +40,9 @@ void DepsgraphRelationBuilder::build_scene_camera(Scene *scene)
if (scene->camera != nullptr) {
build_object(scene->camera);
}
if (scene->gn_camera_override != nullptr) {
build_object(scene->gn_camera_override);
}
LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) {
if (!ELEM(marker->camera, nullptr, scene->camera)) {
build_object(marker->camera);
@@ -92,6 +92,9 @@ void DEG_add_scene_camera_relation(DepsNodeHandle *node_handle,
if (scene->camera != nullptr) {
DEG_add_object_relation(node_handle, scene->camera, component, description);
}
if (scene->gn_camera_override != nullptr) {
DEG_add_object_relation(node_handle, scene->gn_camera_override, component, description);
}
/* Like DepsgraphNodeBuilder::build_scene_camera(), we also need to account for other cameras
* referenced by markers. */
+1 -1
View File
@@ -2027,6 +2027,7 @@ typedef struct Scene {
DrawDataList drawdata;
struct Object *camera;
struct Object *gn_camera_override;
struct World *world;
struct Scene *set;
@@ -2034,7 +2035,6 @@ typedef struct Scene {
ListBase base DNA_DEPRECATED;
/** Active base. */
struct Base *basact DNA_DEPRECATED;
void *_pad1;
/** 3d cursor location. */
View3DCursor cursor;
@@ -2438,12 +2438,17 @@ static void rna_SceneCamera_update(Main * /*bmain*/, Scene * /*scene*/, PointerR
{
Scene *scene = (Scene *)ptr->owner_id;
Object *camera = scene->camera;
Object *gn_camera = scene->gn_camera_override;
SEQ_cache_cleanup(scene);
if (camera && (camera->type == OB_CAMERA)) {
DEG_id_tag_update(&camera->id, ID_RECALC_GEOMETRY);
}
if (gn_camera && (gn_camera->type == OB_CAMERA)) {
DEG_id_tag_update(&gn_camera->id, ID_RECALC_GEOMETRY);
}
}
static void rna_SceneSequencer_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
@@ -8726,6 +8731,14 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Camera", "Active camera, used for rendering the scene");
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_camera_update");
prop = RNA_def_property(srna, "gn_camera_override", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_pointer_funcs(prop, nullptr, nullptr, nullptr, "rna_Camera_object_poll");
RNA_def_property_ui_text(prop, "GeoNodes Active Camera Override", "Active camera, used for calculating geometry nodes active camera node");
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_frame_update");
prop = RNA_def_property(srna, "background_set", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, nullptr, "set");
RNA_def_property_struct_type(prop, "Scene");
@@ -17,8 +17,13 @@ static void node_declare(NodeDeclarationBuilder &b)
static void node_exec(GeoNodeExecParams params)
{
const Scene *scene = DEG_get_evaluated_scene(params.depsgraph());
Object *camera = DEG_get_evaluated_object(params.depsgraph(), scene->camera);
params.set_output("Active Camera", camera);
if (scene->gn_camera_override == nullptr) {
Object *camera = DEG_get_evaluated_object(params.depsgraph(), scene->camera);
params.set_output("Active Camera", camera);
} else {
Object *camera = DEG_get_evaluated_object(params.depsgraph(), scene->gn_camera_override);
params.set_output("Active Camera", camera);
}
}
static void node_register()