class EntityGroupSelected : public scene::Graph::Walker
{
- NodeSmartReference group;
+ NodeSmartReference group, worldspawn;
//typedef std::pair<NodeSmartReference, NodeSmartReference> DeletionPair;
//Stack<DeletionPair> deleteme;
public:
- EntityGroupSelected(const scene::Path &p): group(p.top().get())
+ EntityGroupSelected(const scene::Path &p): group(p.top().get()), worldspawn(Map_FindOrInsertWorldspawn(g_map))
{
}
bool pre(const scene::Path& path, scene::Instance& instance) const
NodeSmartReference child(path.top().get());
NodeSmartReference parent(path.parent().get());
- if(path.size() >= 3 && parent != Map_FindOrInsertWorldspawn(g_map))
+ if(path.size() >= 3 && parent != worldspawn)
{
NodeSmartReference parentparent(path[path.size() - 3].get());
{
GlobalEntityCreator().connectEntities(
GlobalSelectionSystem().penultimateSelected().path(),
- GlobalSelectionSystem().ultimateSelected().path()
+ GlobalSelectionSystem().ultimateSelected().path(),
+ 0
);
}
else
}
}
+void Entity_killconnectSelected()
+{
+ if(GlobalSelectionSystem().countSelected() == 2)
+ {
+ GlobalEntityCreator().connectEntities(
+ GlobalSelectionSystem().penultimateSelected().path(),
+ GlobalSelectionSystem().ultimateSelected().path(),
+ 1
+ );
+ }
+ else
+ {
+ globalErrorStream() << "entityKillConnectSelected: exactly two instances must be selected\n";
+ }
+}
+
AABB Doom3Light_getBounds(const AABB& workzone)
{
AABB aabb(workzone);
EntityClass* entityClass = GlobalEntityClassManager().findOrInsert(name, true);
- bool isModel = string_equal_nocase(name, "misc_model")
- || string_equal_nocase(name, "misc_gamemodel")
+ bool isModel = (string_compare_nocase_n(name, "misc_", 5) == 0 && string_equal_nocase(name + string_length(name) - 5, "model")) // misc_*model (also misc_model)
|| string_equal_nocase(name, "model_static")
|| (GlobalSelectionSystem().countSelected() == 0 && string_equal_nocase(name, "func_static"));
}
}
-
+#if 0
bool DoNormalisedColor(Vector3& color)
{
if(!color_dialog(GTK_WIDGET(MainFrame_getWindow()), color))
return true;
}
+#endif
+
+void NormalizeColor(Vector3& color)
+{
+ // scale colors so that at least one component is at 1.0F
+
+ float largest = 0.0F;
+
+ if ( color[0] > largest )
+ largest = color[0];
+ if ( color[1] > largest )
+ largest = color[1];
+ if ( color[2] > largest )
+ largest = color[2];
+
+ if ( largest == 0.0F )
+ {
+ color[0] = 1.0F;
+ color[1] = 1.0F;
+ color[2] = 1.0F;
+ }
+ else
+ {
+ float scaler = 1.0F / largest;
+
+ color[0] *= scaler;
+ color[1] *= scaler;
+ color[2] *= scaler;
+ }
+}
+
+void Entity_normalizeColor()
+{
+ if(GlobalSelectionSystem().countSelected() != 0)
+ {
+ const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
+ Entity* entity = Node_getEntity(path.top());
+
+ if(entity != 0)
+ {
+ const char* strColor = entity->getKeyValue("_color");
+ if(!string_empty(strColor))
+ {
+ Vector3 rgb;
+ if (string_parse_vector3(strColor, rgb))
+ {
+ g_entity_globals.color_entity = rgb;
+ NormalizeColor(g_entity_globals.color_entity);
+
+ char buffer[128];
+ sprintf(buffer, "%g %g %g", g_entity_globals.color_entity[0],
+ g_entity_globals.color_entity[1],
+ g_entity_globals.color_entity[2]);
+
+ Scene_EntitySetKeyValue_Selected("_color", buffer);
+ }
+ }
+ }
+ }
+}
void Entity_setColour()
{
if(GlobalSelectionSystem().countSelected() != 0)
{
+ bool normalize = false;
const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
Entity* entity = Node_getEntity(path.top());
+
if(entity != 0)
{
const char* strColor = entity->getKeyValue("_color");
}
}
- if(g_pGameDescription->mGameType == "doom3"
- ? color_dialog(GTK_WIDGET(MainFrame_getWindow()), g_entity_globals.color_entity)
- : DoNormalisedColor(g_entity_globals.color_entity))
- {
- char buffer[128];
- sprintf(buffer, "%g %g %g", g_entity_globals.color_entity[0],
- g_entity_globals.color_entity[1],
- g_entity_globals.color_entity[2]);
+ if( g_pGameDescription->mGameType == "doom3" )
+ normalize = false;
- Scene_EntitySetKeyValue_Selected("_color", buffer);
- }
+ if(color_dialog(GTK_WIDGET(MainFrame_getWindow()), g_entity_globals.color_entity))
+ {
+ if( normalize )
+ NormalizeColor(g_entity_globals.color_entity);
+
+ char buffer[128];
+ sprintf(buffer, "%g %g %g", g_entity_globals.color_entity[0],
+ g_entity_globals.color_entity[1],
+ g_entity_globals.color_entity[2]);
+
+ Scene_EntitySetKeyValue_Selected("_color", buffer);
+ }
}
}
}
create_menu_item_with_mnemonic(menu, "_Regroup", "GroupSelection");
create_menu_item_with_mnemonic(menu, "_Ungroup", "UngroupSelection");
create_menu_item_with_mnemonic(menu, "_Connect", "ConnectSelection");
+ create_menu_item_with_mnemonic(menu, "_KillConnect", "KillConnectSelection");
create_menu_item_with_mnemonic(menu, "_Select Color...", "EntityColor");
+ create_menu_item_with_mnemonic(menu, "_Normalize Color...", "NormalizeColor");
}
void Entity_Construct()
{
GlobalCommands_insert("EntityColor", FreeCaller<Entity_setColour>(), Accelerator('K'));
+ GlobalCommands_insert("NormalizeColor", FreeCaller<Entity_normalizeColor>());
GlobalCommands_insert("ConnectSelection", FreeCaller<Entity_connectSelected>(), Accelerator('K', (GdkModifierType)GDK_CONTROL_MASK));
+ GlobalCommands_insert("KillConnectSelection", FreeCaller<Entity_killconnectSelected>(), Accelerator('K', (GdkModifierType)(GDK_SHIFT_MASK)));
GlobalCommands_insert("GroupSelection", FreeCaller<Entity_groupSelected>());
GlobalCommands_insert("UngroupSelection", FreeCaller<Entity_ungroupSelected>());