binds...
* Tab: focus camera on selected
menus...
* Modify->Nudge:+ Nudge +Z, Nudge -Z
misc...
* improvement of: Scale tool: now scales bbox by gridsize increment
* snap transform origin for rotate 90' commands, if one is not custom (is good to stay on grid)
* 2d camera icon in ZY, ZX views represents yaw aswell
* M3 camera direction control: disabled snapping
* M3 camera direction control: affect yaw instead of doing pitch > 90' in ZY, ZX views
* fix of: ctrl+m3 in 2d, release ctrl, then m3: m3 drag works like with ctrl pressed
* removed 2 buttons mouse option: was only affecting m3 camera control binds
* fix of: press any modifier (ctrl/shift/alt) + any mouse, release modifier, then mouse = chase mouse broken
* removed 'Right Button Activates Context Menu' preference
* brushExport plugin, prtview plugin, bobToolz::Polygon Builder, about, textures reset, messagebox windows live on top of main window
* removed 'Update views on camera move' option: camera icon updating is enough quick
* fix: bobToolz::split patch rows+columns - works if rows = 3 ( clos and rows were mixed up in general )
* entitySetColour, entityNormalizeColour are undoable
* bobToolz::splitPatch commands place result into parent entity (worldspawn or group one)
* bobToolz::mergePatches places result into last selected patch's parent entity
* bobToolz::mergePatches: remove left empty group entities
* SelectAllOfType works for group entities, whose brush(es) are selected (no parent node selection needed).
Algorithm is: get [ent inspector's keyName field(if visible) or classname]'s keyValues of selected ents ('no key' counts, as property, too);
Then select ents with according keyName+keyValues; Worldspawn is omitted;
Otherwise (nothing or worldspawn selected) select primitives, holding selected texture;
in 'Faces' component mode = select specifically faces, holding selected texture;
* SelectAllOfType selects child primitives of group entities
* ExpandSelectionToEntities works for worldspawn entity too
int i;
int x, y;
- if ( width >= 5 ) {
+ if ( height >= 5 ) {
std::list<DPatch> patchColList = SplitCols();
for ( std::list<DPatch>::iterator patchesCol = patchColList.begin(); patchesCol != patchColList.end(); patchesCol++ )
{
- std::list<DPatch> patchRowList = ( *patchesCol ).SplitRows();
- for ( std::list<DPatch>::iterator patchesRow = patchRowList.begin(); patchesRow != patchRowList.end(); patchesRow++ )
- {
- patchList.push_front( *patchesRow );
+ if( width >= 5 ){
+ std::list<DPatch> patchRowList = ( *patchesCol ).SplitRows();
+ for ( std::list<DPatch>::iterator patchesRow = patchRowList.begin(); patchesRow != patchRowList.end(); patchesRow++ )
+ {
+ patchList.push_front( *patchesRow );
+ }
+ }
+ else{
+ patchList.push_front( *patchesCol );
}
}
}
- else if ( height >= 5 ) {
+ else if ( width >= 5 ) {
std::list<DPatch> patchRowList = SplitRows();
for ( std::list<DPatch>::iterator patchesRow = patchRowList.begin(); patchesRow != patchRowList.end(); patchesRow++ )
{
#include "dialogs/dialogs-gtk.h"
#include "../../libs/cmdlib.h"
+#include "bobToolz-GTK.h"
+
void BobToolz_construct(){
}
--- /dev/null
+
+#if !defined(INCLUDED_BOBTOOLZGTK_H)
+#define INCLUDED_BOBTOOLZGTK_H
+
+extern GtkWidget *g_pRadiantWnd;
+
+#endif
#include "../lists.h"
#include "../misc.h"
+#include "../bobToolz-GTK.h"
+
/*--------------------------------
Callback Functions
int loop = 1;
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_modal( GTK_WINDOW( window ), TRUE );
gtk_signal_connect( GTK_OBJECT( window ), "delete_event",
GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
gtk_signal_connect( GTK_OBJECT( window ), "destroy",
ret = eIDNO;
}
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT );
gtk_widget_show( window );
gtk_grab_add( window );
int loop = 1;
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
// ---- /vbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( GTK_WINDOW( window ), TRUE );
gtk_widget_show( window );
gtk_grab_add( window );
int loop = 1;
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_modal( GTK_WINDOW( window ), TRUE );
gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
// ---- /vbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT );
gtk_widget_show( window );
gtk_grab_add( window );
gtk_widget_destroy( window );
return ret;
-}
\ No newline at end of file
+}
merge_info = mrgPatches[0].IsMergable( &mrgPatches[1] );
if ( merge_info.mergable ) {
- globalOutputStream() << merge_info.pos1 << " " << merge_info.pos2;
+// globalOutputStream() << merge_info.pos1 << " " << merge_info.pos2;
//Message removed, No tools give feedback on success.
//globalOutputStream() << "bobToolz MergePatches: Patches Mergable.\n";
DPatch* newPatch = mrgPatches[0].MergePatches( merge_info, &mrgPatches[0], &mrgPatches[1] );
}
else
{
+ newPatch->BuildInRadiant( patches[0]->path().parent().get_pointer() );
+
+ scene::Instance& parent = *( patches[1]->parent() );
Path_deleteTop( patches[0]->path() );
Path_deleteTop( patches[1]->path() );
+ Entity* entity = Node_getEntity( parent.path().top() );
+ if ( entity != 0
+ && Node_getTraversable( parent.path().top() )->empty() ) {
+ Path_deleteTop( parent.path() );
+ }
- newPatch->BuildInRadiant();
delete newPatch;
}
}
std::list<DPatch> patchList = patch.Split();
for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
- ( *patches ).BuildInRadiant();
+ ( *patches ).BuildInRadiant( instance.path().parent().get_pointer() );
}
Path_deleteTop( instance.path() );
std::list<DPatch> patchList = patch.SplitCols();
for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
- ( *patches ).BuildInRadiant();
+ ( *patches ).BuildInRadiant( instance.path().parent().get_pointer() );
}
Path_deleteTop( instance.path() );
std::list<DPatch> patchList = patch.SplitRows();
for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
- ( *patches ).BuildInRadiant();
+ ( *patches ).BuildInRadiant( instance.path().parent().get_pointer() );
}
Path_deleteTop( instance.path() );
#include "debugging/debugging.h"
#include "callbacks.h"
#include "support.h"
+#include "plugin.h"
#define GLADE_HOOKUP_OBJECT( component,widget,name ) \
g_object_set_data_full( G_OBJECT( component ), name, \
w_plugplug2 = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_widget_set_name( w_plugplug2, "w_plugplug2" );
gtk_window_set_title( GTK_WINDOW( w_plugplug2 ), "BrushExport-Plugin 3.0 by namespace" );
- gtk_window_set_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER );
+ gtk_window_set_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_transient_for( GTK_WINDOW( w_plugplug2 ), GTK_WINDOW( g_pRadiantWnd ) );
gtk_window_set_destroy_with_parent( GTK_WINDOW( w_plugplug2 ), TRUE );
vbox1 = gtk_vbox_new( FALSE, 0 );
void DestroyWindow( void );
bool IsWindowOpen( void );
+GtkWidget *g_pRadiantWnd = NULL;
+
namespace BrushExport
{
GtkWindow* g_mainwnd;
const char* init( void* hApp, void* pMainWidget ){
g_mainwnd = (GtkWindow*)pMainWidget;
+ g_pRadiantWnd = (GtkWidget*)pMainWidget;
ASSERT_NOTNULL( g_mainwnd );
return "";
}
#if !defined( INCLUDED_BRUSH_EXPORT_H )
#define INCLUDED_BRUSH_EXPORT_H
+typedef struct _GtkWidget GtkWidget;
+extern GtkWidget *g_pRadiantWnd;
+
#endif
int loop = 1, ret = IDCANCEL;
dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE );
gtk_window_set_title( GTK_WINDOW( dlg ), "About Portal Viewer" );
gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
clr[2] = ( (double)GetBValue( *c ) ) / 255.0;
dlg = gtk_color_selection_dialog_new( "Choose Color" );
+ gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE );
gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr );
gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
GtkObject *adj;
dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE );
gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" );
gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
int loop = 1;
file_sel = gtk_file_selection_new( "Locate portal (.prt) file" );
+ gtk_window_set_transient_for( GTK_WINDOW( file_sel ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_position( GTK_WINDOW( file_sel ),GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( GTK_WINDOW( file_sel ), TRUE );
gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->ok_button ), "clicked",
GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDOK ) );
gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->cancel_button ), "clicked",
int loop = 1, ret = IDCANCEL;
dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE );
gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" );
gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
Q3R_CMD_LOAD;
+GtkWidget *g_pRadiantWnd = NULL;
const char* QERPlug_Init( void *hApp, void* pMainWidget ){
+ g_pRadiantWnd = (GtkWidget*)pMainWidget;
return "Portal Viewer for Q3Radiant";
}
int INIGetInt( char *key, int def );
void INISetInt( char *key, int val, char *comment = 0 );
+typedef struct _GtkWidget GtkWidget;
+extern GtkWidget *g_pRadiantWnd;
+
#define IDOK 1
#define IDCANCEL 2
virtual void NudgeManipulator( const Vector3& nudge, const Vector3& view ) = 0;
virtual void translateSelected( const Vector3& translation ) = 0;
-virtual void rotateSelected( const Quaternion& rotation ) = 0;
+virtual void rotateSelected( const Quaternion& rotation, bool snapOrigin ) = 0;
virtual void scaleSelected( const Vector3& scaling ) = 0;
virtual void pivotChanged() const = 0;
camera_t& getCamera(){
return m_Camera;
-};
+}
void BenchMark();
void Cam_ChangeFloor( bool up );
Camera_setAngles( camwnd, angles );
}
+#include "select.h"
+
+void GlobalCamera_FocusOnSelected(){
+ CamWnd& camwnd = *g_camwnd;
+
+ Vector3 angles( Camera_getAngles( camwnd ) );
+ Vector3 radangles( degrees_to_radians( angles[0] ), degrees_to_radians( angles[1] ), degrees_to_radians( angles[2] ) );
+ Vector3 viewvector;
+ viewvector[0] = cos( radangles[1] ) * cos( radangles[0] );
+ viewvector[1] = sin( radangles[1] ) * cos( radangles[0] );
+ viewvector[2] = sin( radangles[0] );
+
+ Vector3 camorigin( Camera_getOrigin( camwnd ) );
+
+ AABB aabb( aabb_for_minmax( Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max ) );
+
+ View& view = *( camwnd.getCamera().m_view );
+
+ Plane3 frustumPlanes[4];
+ frustumPlanes[0] = plane3_translated( view.getFrustum().left, camorigin - aabb.origin );
+ frustumPlanes[1] = plane3_translated( view.getFrustum().right, camorigin - aabb.origin );
+ frustumPlanes[2] = plane3_translated( view.getFrustum().top, camorigin - aabb.origin );
+ frustumPlanes[3] = plane3_translated( view.getFrustum().bottom, camorigin - aabb.origin );
+
+ float offset = 64.0f;
+
+ Vector3 corners[8];
+ aabb_corners( aabb, corners );
+
+ for ( size_t i = 0; i < 4; ++i ){
+ for ( size_t j = 0; j < 8; ++j ){
+ Ray ray( aabb.origin, -viewvector );
+ //Plane3 newplane( frustumPlanes[i].normal(), vector3_dot( frustumPlanes[i].normal(), corners[j] - frustumPlanes[i].normal() * 16.0f ) );
+ Plane3 newplane( frustumPlanes[i].normal(), vector3_dot( frustumPlanes[i].normal(), corners[j] ) );
+ float d = vector3_dot( ray.direction, newplane.normal() );
+ if( d != 0 ){
+ float s = vector3_dot( newplane.normal() * newplane.dist() - ray.origin, newplane.normal() ) / d;
+ offset = std::max( offset, s );
+ }
+ }
+ }
+ Camera_setOrigin( camwnd, aabb.origin - viewvector * offset );
+}
+
void Camera_ChangeFloorUp(){
CamWnd& camwnd = *g_camwnd;
camwnd.Cam_ChangeFloor( true );
/// \brief Initialisation for things that have the same lifespan as this module.
void CamWnd_Construct(){
GlobalCommands_insert( "CenterView", FreeCaller<GlobalCamera_ResetAngles>(), Accelerator( GDK_End ) );
+ GlobalCommands_insert( "CameraFocusOnSelected", FreeCaller<GlobalCamera_FocusOnSelected>(), Accelerator( GDK_Tab ) );
GlobalToggles_insert( "ToggleCubicClip", FreeCaller<Camera_ToggleFarClip>(), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "CubicClipZoomIn", FreeCaller<Camera_CubeIn>(), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) );
g_entity_globals.color_entity[1],
g_entity_globals.color_entity[2] );
+ StringOutputStream command( 256 );
+ command << "entityNormalizeColour " << buffer;
+ UndoableCommand undo( command.c_str() );
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 ( !string_empty( strColor ) ) {
g_entity_globals.color_entity = rgb;
}
}
-
- if ( g_pGameDescription->mGameType == "doom3" ) {
- normalize = false;
- }
-
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] );
+ StringOutputStream command( 256 );
+ command << "entitySetColour " << buffer;
+ UndoableCommand undo( command.c_str() );
Scene_EntitySetKeyValue_Selected( "_color", buffer );
}
}
};
layout_globals_t g_layout_globals;
-glwindow_globals_t g_glwindow_globals;
+//glwindow_globals_t g_glwindow_globals;
// VFS
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( camera_menu );
}
+ create_menu_item_with_mnemonic( camera_menu, "Focus on Selected", "CameraFocusOnSelected" );
create_menu_item_with_mnemonic( camera_menu, "_Center", "CenterView" );
create_menu_item_with_mnemonic( camera_menu, "_Up Floor", "UpFloor" );
create_menu_item_with_mnemonic( camera_menu, "_Down Floor", "DownFloor" );
create_menu_item_with_mnemonic( menu_in_menu, "Nudge Right", "SelectNudgeRight" );
create_menu_item_with_mnemonic( menu_in_menu, "Nudge Up", "SelectNudgeUp" );
create_menu_item_with_mnemonic( menu_in_menu, "Nudge Down", "SelectNudgeDown" );
+ menu_separator( menu_in_menu );
+ create_menu_item_with_mnemonic( menu_in_menu, "Nudge +Z", "MoveSelectionUP" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Nudge -Z", "MoveSelectionDOWN" );
}
{
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" );
create_game_help_menu( menu );
// create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller<OpenBugReportURL>() );
- create_menu_item_with_mnemonic( menu, "Shortcuts list", FreeCaller<DoCommandListDlg>() );
+ create_menu_item_with_mnemonic( menu, "Shortcuts", FreeCaller<DoCommandListDlg>() );
create_menu_item_with_mnemonic( menu, "_About", FreeCaller<DoAbout>() );
return help_menu_item;
}
void SelectNudge_registerShortcuts(){
- command_connect_accelerator( "MoveSelectionDOWN" );
- command_connect_accelerator( "MoveSelectionUP" );
+ //command_connect_accelerator( "MoveSelectionDOWN" );
+ //command_connect_accelerator( "MoveSelectionUP" );
//command_connect_accelerator("SelectNudgeLeft");
//command_connect_accelerator("SelectNudgeRight");
//command_connect_accelerator("SelectNudgeUp");
void GLWindow_Construct(){
- GlobalPreferenceSystem().registerPreference( "MouseButtons", IntImportStringCaller( g_glwindow_globals.m_nMouseType ), IntExportStringCaller( g_glwindow_globals.m_nMouseType ) );
+// GlobalPreferenceSystem().registerPreference( "MouseButtons", IntImportStringCaller( g_glwindow_globals.m_nMouseType ), IntExportStringCaller( g_glwindow_globals.m_nMouseType ) );
}
void GLWindow_Destroy(){
extern MainFrame* g_pParentWnd;
GtkWindow* MainFrame_getWindow();
-
+/*
enum EMouseButtonMode
{
ETwoButton = 0,
m_nMouseType( EThreeButton ){
}
};
-
+*/
void GLWindow_Construct();
void GLWindow_Destroy();
-extern glwindow_globals_t g_glwindow_globals;
+//extern glwindow_globals_t g_glwindow_globals;
template<typename Value>
class LatchedValue;
typedef LatchedValue<bool> LatchedBool;
}
void Mouse_constructPreferences( PreferencesPage& page ){
- {
- const char* buttons[] = { "2 button", "3 button", };
- page.appendRadio( "Mouse Type", g_glwindow_globals.m_nMouseType, STRING_ARRAY_RANGE( buttons ) );
- }
- page.appendCheckBox( "Right Button", "Activates Context Menu", g_xywindow_globals.m_bRightClick );
+// {
+// const char* buttons[] = { "2 button", "3 button", };
+// page.appendRadio( "Mouse Type", g_glwindow_globals.m_nMouseType, STRING_ARRAY_RANGE( buttons ) );
+// }
+// page.appendCheckBox( "Right Button", "Activates Context Menu", g_xywindow_globals.m_bRightClick );
page.appendCheckBox( "", "Improved mousewheel zoom", g_xywindow_globals.m_bImprovedWheelZoom );
}
void Mouse_constructPage( PreferenceGroup& group ){
Scene_Invert_Selection( GlobalSceneGraph() );
}
+//interesting printings
+class ExpandSelectionToEntitiesWalker_dbg : public scene::Graph::Walker
+{
+mutable std::size_t m_depth;
+NodeSmartReference worldspawn;
+public:
+ExpandSelectionToEntitiesWalker_dbg() : m_depth( 0 ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
+}
+bool pre( const scene::Path& path, scene::Instance& instance ) const {
+ ++m_depth;
+ globalOutputStream() << "pre depth_" << m_depth;
+ globalOutputStream() << " path.size()_" << path.size();
+ if ( path.top().get() == worldspawn )
+ globalOutputStream() << " worldspawn";
+ if( path.top().get().isRoot() )
+ globalOutputStream() << " path.top().get().isRoot()";
+ Entity* entity = Node_getEntity( path.top() );
+ if ( entity != 0 ){
+ globalOutputStream() << " entity!=0";
+ if( entity->isContainer() ){
+ globalOutputStream() << " entity->isContainer()";
+ }
+ globalOutputStream() << " classname_" << entity->getKeyValue( "classname" );
+ }
+ globalOutputStream() << "\n";
+// globalOutputStream() << "" << ;
+// globalOutputStream() << "" << ;
+// globalOutputStream() << "" << ;
+// globalOutputStream() << "" << ;
+ return true;
+}
+void post( const scene::Path& path, scene::Instance& instance ) const {
+ globalOutputStream() << "post depth_" << m_depth;
+ globalOutputStream() << " path.size()_" << path.size();
+ if ( path.top().get() == worldspawn )
+ globalOutputStream() << " worldspawn";
+ if( path.top().get().isRoot() )
+ globalOutputStream() << " path.top().get().isRoot()";
+ Entity* entity = Node_getEntity( path.top() );
+ if ( entity != 0 ){
+ globalOutputStream() << " entity!=0";
+ if( entity->isContainer() ){
+ globalOutputStream() << " entity->isContainer()";
+ }
+ globalOutputStream() << " classname_" << entity->getKeyValue( "classname" );
+ }
+ globalOutputStream() << "\n";
+ --m_depth;
+}
+};
+
class ExpandSelectionToEntitiesWalker : public scene::Graph::Walker
{
mutable std::size_t m_depth;
++m_depth;
// ignore worldspawn
- NodeSmartReference me( path.top().get() );
- if ( me == worldspawn ) {
- return false;
- }
+// NodeSmartReference me( path.top().get() );
+// if ( me == worldspawn ) {
+// return false;
+// }
if ( m_depth == 2 ) { // entity depth
// traverse and select children if any one is selected
+ bool beselected = false;
if ( instance.childSelected() ) {
- Instance_setSelected( instance, true );
+ beselected = true;
+ if( path.top().get() != worldspawn ){
+ Instance_setSelected( instance, true );
+ }
}
- return Node_getEntity( path.top() )->isContainer() && instance.isSelected();
+ return Node_getEntity( path.top() )->isContainer() && beselected;
}
else if ( m_depth == 3 ) { // primitive depth
Instance_setSelected( instance, true );
void Select_RotateAxis( int axis, float deg ){
if ( fabs( deg ) == 90.f ) {
- GlobalSelectionSystem().rotateSelected( quaternion_for_axis90( (axis_t)axis, ( deg > 0 ) ? eSignPositive : eSignNegative ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_axis90( (axis_t)axis, ( deg > 0 ) ? eSignPositive : eSignNegative ), true );
}
else
{
switch ( axis )
{
case 0:
- GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_x_degrees( deg ) ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_x_degrees( deg ) ), false );
break;
case 1:
- GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_y_degrees( deg ) ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_y_degrees( deg ) ), false );
break;
case 2:
- GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_z_degrees( deg ) ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_z_degrees( deg ) ), false );
break;
}
}
{
const PropertyValues& m_propertyvalues;
const char *m_prop;
+const NodeSmartReference worldspawn;
public:
EntityFindByPropertyValueWalker( const char *prop, const PropertyValues& propertyvalues )
- : m_propertyvalues( propertyvalues ), m_prop( prop ){
+ : m_propertyvalues( propertyvalues ), m_prop( prop ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if( !path.top().get().visible() ){
return false;
}
+ // ignore worldspawn
+ if ( path.top().get() == worldspawn ) {
+ return false;
+ }
+
Entity* entity = Node_getEntity( path.top() );
- if ( entity != 0
- && propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
- Instance_getSelectable( instance )->setSelected( true );
+ if ( entity != 0 ){
+ if( propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
+ Instance_getSelectable( instance )->setSelected( true );
+ return true;
+ }
+ return false;
+ }
+ else if( path.size() > 2 && !path.top().get().isRoot() ){
+ Selectable* selectable = Instance_getSelectable( instance );
+ if( selectable != 0 )
+ selectable->setSelected( true );
}
return true;
}
{
PropertyValues& m_propertyvalues;
const char *m_prop;
+const NodeSmartReference worldspawn;
public:
EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propertyvalues )
- : m_propertyvalues( propertyvalues ), m_prop( prop ){
+ : m_propertyvalues( propertyvalues ), m_prop( prop ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
+}
+bool pre( const scene::Path& path, scene::Instance& instance ) const {
+ Entity* entity = Node_getEntity( path.top() );
+ if ( entity != 0 ){
+ if( path.top().get() != worldspawn ){
+ Selectable* selectable = Instance_getSelectable( instance );
+ if ( ( selectable != 0 && selectable->isSelected() ) || instance.childSelected() ) {
+ if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
+ m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
+ }
+ }
+ }
+ return false;
+ }
+ return true;
+}
+};
+/*
+class EntityGetSelectedPropertyValuesWalker : public scene::Graph::Walker
+{
+PropertyValues& m_propertyvalues;
+const char *m_prop;
+mutable bool m_selected_children;
+const NodeSmartReference worldspawn;
+public:
+EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propertyvalues )
+ : m_propertyvalues( propertyvalues ), m_prop( prop ), m_selected_children( false ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
}
+ return false;
+ }
+ else{
+ m_selected_children = true;
}
}
return true;
}
+void post( const scene::Path& path, scene::Instance& instance ) const {
+ Entity* entity = Node_getEntity( path.top() );
+ if( entity != 0 && m_selected_children ){
+ m_selected_children = false;
+ if( path.top().get() == worldspawn )
+ return;
+ if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
+ m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
+ }
+ }
+}
};
-
+*/
void Scene_EntityGetPropertyValues( scene::Graph& graph, const char *prop, PropertyValues& propertyvalues ){
graph.traverse( EntityGetSelectedPropertyValuesWalker( prop, propertyvalues ) );
}
command << "rotateSelectedEulerXYZ -x " << eulerXYZ[0] << " -y " << eulerXYZ[1] << " -z " << eulerXYZ[2];
UndoableCommand undo( command.c_str() );
- GlobalSelectionSystem().rotateSelected( quaternion_for_euler_xyz_degrees( eulerXYZ ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_euler_xyz_degrees( eulerXYZ ), false );
return TRUE;
}
Vector3 m_axis;
Scalable& m_scalable;
-AABB m_aabb;
-Vector3 m_transform_origin;
Vector3 m_choosen_extent;
public:
void Construct( const Matrix4& device2manip, const float x, const float y ){
point_on_axis( m_start, m_axis, device2manip, x, y );
- GetSelectionAABB( m_aabb );
- m_transform_origin = vector4_to_vector3( ssGetPivot2World().t() );
- m_choosen_extent = Vector3( std::max( m_aabb.origin[0] + m_aabb.extents[0] - m_transform_origin[0], - m_aabb.origin[0] + m_aabb.extents[0] + m_transform_origin[0] ),
- std::max( m_aabb.origin[1] + m_aabb.extents[1] - m_transform_origin[1], - m_aabb.origin[1] + m_aabb.extents[1] + m_transform_origin[1] ),
- std::max( m_aabb.origin[2] + m_aabb.extents[2] - m_transform_origin[2], - m_aabb.origin[2] + m_aabb.extents[2] + m_transform_origin[2] )
+ AABB aabb;
+ GetSelectionAABB( aabb );
+ Vector3 transform_origin = vector4_to_vector3( ssGetPivot2World().t() );
+ m_choosen_extent = Vector3( std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
+ std::max( aabb.origin[1] + aabb.extents[1] - transform_origin[1], - aabb.origin[1] + aabb.extents[1] + transform_origin[1] ),
+ std::max( aabb.origin[2] + aabb.extents[2] - transform_origin[2], - aabb.origin[2] + aabb.extents[2] + transform_origin[2] )
);
}
Vector3 m_start;
Scalable& m_scalable;
-AABB m_aabb;
-Vector3 m_transform_origin;
Vector3 m_choosen_extent;
public:
void Construct( const Matrix4& device2manip, const float x, const float y ){
point_on_plane( m_start, device2manip, x, y );
- GetSelectionAABB( m_aabb );
- m_transform_origin = vector4_to_vector3( ssGetPivot2World().t() );
- m_choosen_extent = Vector3( std::max( m_aabb.origin[0] + m_aabb.extents[0] - m_transform_origin[0], - m_aabb.origin[0] + m_aabb.extents[0] + m_transform_origin[0] ),
- std::max( m_aabb.origin[1] + m_aabb.extents[1] - m_transform_origin[1], - m_aabb.origin[1] + m_aabb.extents[1] + m_transform_origin[1] ),
- std::max( m_aabb.origin[2] + m_aabb.extents[2] - m_transform_origin[2], - m_aabb.origin[2] + m_aabb.extents[2] + m_transform_origin[2] )
+ AABB aabb;
+ GetSelectionAABB( aabb );
+ Vector3 transform_origin = vector4_to_vector3( ssGetPivot2World().t() );
+ m_choosen_extent = Vector3( std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
+ std::max( aabb.origin[1] + aabb.extents[1] - transform_origin[1], - aabb.origin[1] + aabb.extents[1] + transform_origin[1] ),
+ std::max( aabb.origin[2] + aabb.extents[2] - transform_origin[2], - aabb.origin[2] + aabb.extents[2] + transform_origin[2] )
);
}
void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
ostream << " -scale " << m_scale.x() << " " << m_scale.y() << " " << m_scale.z();
}
-void rotateSelected( const Quaternion& rotation ){
+void rotateSelected( const Quaternion& rotation, bool snapOrigin ){
+ if( snapOrigin && !m_pivotIsCustom ){
+ m_pivot2world.tx() = float_snapped( m_pivot2world.tx(), GetSnapGridSize() );
+ m_pivot2world.ty() = float_snapped( m_pivot2world.ty(), GetSnapGridSize() );
+ m_pivot2world.tz() = float_snapped( m_pivot2world.tz(), GetSnapGridSize() );
+ }
startMove();
rotate( rotation );
freezeTransforms();
const Vector3& getViewer() const {
return vector4_to_vector3( m_viewer );
}
+const Frustum& getFrustum() const {
+ return m_frustum;
+}
};
#endif
bool show_blocks;
int blockSize;
- bool m_bCamXYUpdate;
+// bool m_bCamXYUpdate;
bool m_bChaseMouse;
bool m_bSizePaint;
show_blocks( false ),
- m_bCamXYUpdate( true ),
+// m_bCamXYUpdate( true ),
m_bChaseMouse( true ),
m_bSizePaint( true ){
}
void XYWnd_CameraMoved( XYWnd& xywnd ){
- if ( g_xywindow_globals_private.m_bCamXYUpdate ) {
+// if ( g_xywindow_globals_private.m_bCamXYUpdate ) {
//XYWnd_Update( xywnd );
xywnd.UpdateCameraIcon();
- }
+// }
}
XYWnd::XYWnd() :
}
unsigned int MoveCamera_buttons(){
- return RAD_CONTROL | ( g_glwindow_globals.m_nMouseType == ETwoButton ? RAD_RBUTTON : RAD_MBUTTON );
+// return RAD_CONTROL | ( g_glwindow_globals.m_nMouseType == ETwoButton ? RAD_RBUTTON : RAD_MBUTTON );
+ return RAD_CONTROL | RAD_MBUTTON;
}
void XYWnd_PositionCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
}
unsigned int OrientCamera_buttons(){
- if ( g_glwindow_globals.m_nMouseType == ETwoButton ) {
- return RAD_RBUTTON | RAD_SHIFT | RAD_CONTROL;
- }
+// if ( g_glwindow_globals.m_nMouseType == ETwoButton ) {
+// return RAD_RBUTTON | RAD_SHIFT | RAD_CONTROL;
+// }
return RAD_MBUTTON;
}
void XYWnd_OrientCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
+ //globalOutputStream() << Camera_getAngles( camwnd ) << " b4\n";
Vector3 point = g_vector3_identity;
xywnd->XY_ToPoint( x, y, point );
- xywnd->XY_SnapToGrid( point );
+ //xywnd->XY_SnapToGrid( point );
vector3_subtract( point, Camera_getOrigin( camwnd ) );
int n1 = ( xywnd->GetViewType() == XY ) ? 1 : 2;
if ( point[n1] || point[n2] ) {
Vector3 angles( Camera_getAngles( camwnd ) );
angles[nAngle] = static_cast<float>( radians_to_degrees( atan2( point[n1], point[n2] ) ) );
+ if( angles[CAMERA_YAW] < 0 )
+ angles[CAMERA_YAW] = angles[CAMERA_YAW] + 360;
+ if ( nAngle == CAMERA_PITCH ){
+ if( fabs( angles[CAMERA_PITCH] ) > 90 ){
+ angles[CAMERA_PITCH] = ( angles[CAMERA_PITCH] > 0 ) ? ( -angles[CAMERA_PITCH] + 180 ) : ( -angles[CAMERA_PITCH] - 180 );
+ if( xywnd->GetViewType() == YZ ){
+ if( angles[CAMERA_YAW] < 180 ){
+ angles[CAMERA_YAW] = 360 - angles[CAMERA_YAW];
+ }
+ }
+ else if( angles[CAMERA_YAW] < 90 || angles[CAMERA_YAW] > 270 ){
+ angles[CAMERA_YAW] = 180 - angles[CAMERA_YAW];
+ }
+ }
+ else{
+ if( xywnd->GetViewType() == YZ ){
+ if( angles[CAMERA_YAW] > 180 ){
+ angles[CAMERA_YAW] = 360 - angles[CAMERA_YAW];
+ }
+ }
+ else if( angles[CAMERA_YAW] > 90 && angles[CAMERA_YAW] < 270 ){
+ angles[CAMERA_YAW] = 180 - angles[CAMERA_YAW];
+ }
+ }
+ }
Camera_setAngles( camwnd, angles );
}
+ //globalOutputStream() << Camera_getAngles( camwnd ) << "\n";
}
unsigned int SetCustomPivotOrigin_buttons(){
};
void XYWnd::OnContextMenu(){
- if ( g_xywindow_globals.m_bRightClick == false ) {
- return;
- }
+// if ( g_xywindow_globals.m_bRightClick == false ) {
+// return;
+// }
if ( m_mnuDrop == 0 ) { // first time, load it up
GtkMenu* menu = m_mnuDrop = GTK_MENU( gtk_menu_new() );
}
// control mbutton = move camera
- else if ( getButtonState() == MoveCamera_buttons() ) {
+ else if ( buttons == MoveCamera_buttons() ) {
XYWnd_PositionCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
}
// mbutton = angle camera
- else if ( getButtonState() == OrientCamera_buttons() ) {
+ else if ( buttons == OrientCamera_buttons() ) {
XYWnd_OrientCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
}
void XYWnd::DrawCameraIcon( const Vector3& origin, const Vector3& angles ){
Cam.fov = 48 / m_fScale;
Cam.box = 16 / m_fScale;
+// globalOutputStream() << "pitch " << angles[CAMERA_PITCH] << " yaw " << angles[CAMERA_YAW] << "\n";
if ( m_viewType == XY ) {
Cam.x = origin[0];
else if ( m_viewType == YZ ) {
Cam.x = origin[1];
Cam.y = origin[2];
- Cam.a = degrees_to_radians( angles[CAMERA_PITCH] );
+ Cam.a = degrees_to_radians( ( angles[CAMERA_YAW] > 180 ) ? ( 180.0f - angles[CAMERA_PITCH] ) : angles[CAMERA_PITCH] );
}
else
{
Cam.x = origin[0];
Cam.y = origin[2];
- Cam.a = degrees_to_radians( angles[CAMERA_PITCH] );
+ Cam.a = degrees_to_radians( ( angles[CAMERA_YAW] < 270 && angles[CAMERA_YAW] > 90 ) ? ( 180.0f - angles[CAMERA_PITCH] ) : angles[CAMERA_PITCH] );
}
//glColor3f( 0.0, 0.0, 1.0 );
page.appendCheckBox( "", "Solid selection boxes ( no stipple )", g_xywindow_globals.m_bNoStipple );
//page.appendCheckBox( "", "Display size info", g_xywindow_globals_private.m_bSizePaint );
page.appendCheckBox( "", "Chase mouse during drags", g_xywindow_globals_private.m_bChaseMouse );
- page.appendCheckBox( "", "Update views on camera move", g_xywindow_globals_private.m_bCamXYUpdate );
+// page.appendCheckBox( "", "Update views on camera move", g_xywindow_globals_private.m_bCamXYUpdate );
}
void Orthographic_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Orthographic", "Orthographic View Preferences" ) );
GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) );
- GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) );
+// GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) );
GlobalPreferenceSystem().registerPreference( "ImprovedWheelZoom", BoolImportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ), BoolExportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ) );
GlobalPreferenceSystem().registerPreference( "ChaseMouse", BoolImportStringCaller( g_xywindow_globals_private.m_bChaseMouse ), BoolExportStringCaller( g_xywindow_globals_private.m_bChaseMouse ) );
GlobalPreferenceSystem().registerPreference( "SizePainting", BoolImportStringCaller( g_xywindow_globals_private.m_bSizePaint ), BoolExportStringCaller( g_xywindow_globals_private.m_bSizePaint ) );
GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", BoolImportStringCaller( g_xywindow_globals_private.show_coordinates ), BoolExportStringCaller( g_xywindow_globals_private.show_coordinates ) );
GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", BoolImportStringCaller( g_xywindow_globals_private.show_outline ), BoolExportStringCaller( g_xywindow_globals_private.show_outline ) );
GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", BoolImportStringCaller( g_xywindow_globals_private.show_axis ), BoolExportStringCaller( g_xywindow_globals_private.show_axis ) );
- GlobalPreferenceSystem().registerPreference( "CamXYUpdate", BoolImportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ), BoolExportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ) );
+// GlobalPreferenceSystem().registerPreference( "CamXYUpdate", BoolImportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ), BoolExportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ) );
GlobalPreferenceSystem().registerPreference( "ShowWorkzone", BoolImportStringCaller( g_xywindow_globals_private.d_show_work ), BoolExportStringCaller( g_xywindow_globals_private.d_show_work ) );
GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", Vector3ImportStringCaller( g_xywindow_globals.AxisColorX ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorX ) );
public:
void ButtonState_onMouseDown( unsigned int buttons ){
- m_buttonstate |= buttons;
+ //m_buttonstate |= buttons;
+ m_buttonstate = buttons;
}
void ButtonState_onMouseUp( unsigned int buttons ){
- m_buttonstate &= ~buttons;
+ //m_buttonstate &= ~buttons;
+ m_buttonstate = 0;
}
unsigned int getButtonState() const {
return m_buttonstate;
Vector3 AxisColorY;
Vector3 AxisColorZ;
- bool m_bRightClick;
+// bool m_bRightClick;
bool m_bNoStipple;
bool m_bImprovedWheelZoom;
AxisColorX( 1.f, 0.f, 0.f ),
AxisColorY( 0.f, 1.f, 0.f ),
AxisColorZ( 0.f, 0.f, 1.f ),
- m_bRightClick( true ),
+// m_bRightClick( true ),
m_bNoStipple( true ),
m_bImprovedWheelZoom( true ){
}