From b361e76d8f6bbed16d98d00b40cd080a7d446bf4 Mon Sep 17 00:00:00 2001 From: spog Date: Fri, 31 Mar 2006 20:45:34 +0000 Subject: [PATCH] changed doom3/quake4 light creation to use size of selected brushes git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@42 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- CHANGES | 4 ++++ radiant/entity.cpp | 57 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 823233ea..3ab71a63 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ This is the changelog for developers, != changelog for the end user that we distribute with the binaries. (see changelog) +31/03/2006 +SPoG +- Changed doom3 light creation to use size of selected brushes. + 20/03/2006 SPoG - Fixed crash when resetting preferences after startup failure. diff --git a/radiant/entity.cpp b/radiant/entity.cpp index bed3a6cf..122ebf97 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -178,7 +178,31 @@ void Entity_connectSelected() } } +const float Doom3Light_defaultRadius = 300; +AABB Doom3Light_getBounds(const AABB& workzone) +{ + AABB aabb(workzone); + + if(aabb.extents[0] == 0) + { + aabb.extents[0] = Doom3Light_defaultRadius; + } + if(aabb.extents[1] == 0) + { + aabb.extents[1] = Doom3Light_defaultRadius; + } + if(aabb.extents[2] == 0) + { + aabb.extents[2] = Doom3Light_defaultRadius; + } + + if(aabb_valid(aabb)) + { + return aabb; + } + return AABB(Vector3(0, 0, 0), Vector3(64, 64, 64)); +} int g_iLastLightIntensity; @@ -199,12 +223,16 @@ void Entity_createFromSelection(const char* name, const Vector3& origin) || string_equal_nocase(name, "model_static") || (GlobalSelectionSystem().countSelected() == 0 && string_equal_nocase(name, "func_static")); - if(!(entityClass->fixedsize || isModel) && Scene_countSelectedBrushes(GlobalSceneGraph()) == 0) + bool brushesSelected = Scene_countSelectedBrushes(GlobalSceneGraph()) != 0; + + if(!(entityClass->fixedsize || isModel) && !brushesSelected) { globalErrorStream() << "failed to create a group entity - no brushes are selected\n"; return; } + AABB workzone(aabb_for_minmax(Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max)); + NodeSmartReference node(GlobalEntityCreator().createEntity(entityClass)); @@ -257,16 +285,29 @@ void Entity_createFromSelection(const char* name, const Vector3& origin) } } } - else if(g_pGameDescription->mGameType != "doom3" && string_equal_nocase(name, "light")) + else if(string_equal_nocase(name, "light")) { - int intensity = g_iLastLightIntensity; + if(g_pGameDescription->mGameType != "doom3") + { + int intensity = g_iLastLightIntensity; - if (DoLightIntensityDlg (&intensity) == eIDOK) + if (DoLightIntensityDlg (&intensity) == eIDOK) + { + g_iLastLightIntensity = intensity; + char buf[10]; + sprintf( buf, "%d", intensity ); + Node_getEntity(node)->setKeyValue("light", buf); + } + } + else if(brushesSelected) // use workzone to set light position/size for doom3 lights, if there are brushes selected { - g_iLastLightIntensity = intensity; - char buf[10]; - sprintf( buf, "%d", intensity ); - Node_getEntity(node)->setKeyValue("light", buf); + AABB bounds(Doom3Light_getBounds(workzone)); + StringOutputStream key(64); + key << bounds.origin[0] << " " << bounds.origin[1] << " " << bounds.origin[2]; + Node_getEntity(node)->setKeyValue("origin", key.c_str()); + key.clear(); + key << bounds.extents[0] << " " << bounds.extents[1] << " " << bounds.extents[2]; + Node_getEntity(node)->setKeyValue("light_radius", key.c_str()); } } -- 2.39.2