ToggleGridSnap command (beware of it)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@401 61c419a2-8eb2-4b30-bcec-8cead039b335
This commit is contained in:
parent
da366187d6
commit
04a61593c3
|
|
@ -105,6 +105,8 @@ template<typename Element, typename OtherElement>
|
||||||
inline Element float_snapped(const Element& f, const OtherElement& snap)
|
inline Element float_snapped(const Element& f, const OtherElement& snap)
|
||||||
{
|
{
|
||||||
//return Element(float_to_integer(f / snap) * snap);
|
//return Element(float_to_integer(f / snap) * snap);
|
||||||
|
if(snap == 0)
|
||||||
|
return f;
|
||||||
return Element(llrint(f / snap) * snap); // llrint has more significant bits
|
return Element(llrint(f / snap) * snap); // llrint has more significant bits
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,8 @@ int g_grid_default = GridDefault_forGridPower(GRIDPOWER_8);
|
||||||
|
|
||||||
int g_grid_power = GridPower_forGridDefault(g_grid_default);
|
int g_grid_power = GridPower_forGridDefault(g_grid_default);
|
||||||
|
|
||||||
|
bool g_grid_snap = true;
|
||||||
|
|
||||||
int Grid_getPower()
|
int Grid_getPower()
|
||||||
{
|
{
|
||||||
return g_grid_power;
|
return g_grid_power;
|
||||||
|
|
@ -110,6 +112,11 @@ inline float GridSize_forGridPower(int gridPower)
|
||||||
|
|
||||||
float g_gridsize = GridSize_forGridPower(g_grid_power);
|
float g_gridsize = GridSize_forGridPower(g_grid_power);
|
||||||
|
|
||||||
|
float GetSnapGridSize()
|
||||||
|
{
|
||||||
|
return g_grid_snap ? g_gridsize : 0;
|
||||||
|
}
|
||||||
|
|
||||||
float GetGridSize()
|
float GetGridSize()
|
||||||
{
|
{
|
||||||
return g_gridsize;
|
return g_gridsize;
|
||||||
|
|
@ -159,6 +166,7 @@ GridMenuItem g_gridMenu256(GRIDPOWER_256);
|
||||||
|
|
||||||
void setGridPower(GridPower power)
|
void setGridPower(GridPower power)
|
||||||
{
|
{
|
||||||
|
g_grid_snap = true;
|
||||||
g_gridsize = GridSize_forGridPower(power);
|
g_gridsize = GridSize_forGridPower(power);
|
||||||
|
|
||||||
g_gridMenu0125.m_item.update();
|
g_gridMenu0125.m_item.update();
|
||||||
|
|
@ -178,6 +186,7 @@ void setGridPower(GridPower power)
|
||||||
|
|
||||||
void GridPrev()
|
void GridPrev()
|
||||||
{
|
{
|
||||||
|
g_grid_snap = true;
|
||||||
if(g_grid_power > GRIDPOWER_0125)
|
if(g_grid_power > GRIDPOWER_0125)
|
||||||
{
|
{
|
||||||
setGridPower(static_cast<GridPower>(--g_grid_power));
|
setGridPower(static_cast<GridPower>(--g_grid_power));
|
||||||
|
|
@ -186,18 +195,26 @@ void GridPrev()
|
||||||
|
|
||||||
void GridNext()
|
void GridNext()
|
||||||
{
|
{
|
||||||
|
g_grid_snap = true;
|
||||||
if(g_grid_power < GRIDPOWER_256)
|
if(g_grid_power < GRIDPOWER_256)
|
||||||
{
|
{
|
||||||
setGridPower(static_cast<GridPower>(++g_grid_power));
|
setGridPower(static_cast<GridPower>(++g_grid_power));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToggleGridSnap()
|
||||||
|
{
|
||||||
|
g_grid_snap = !g_grid_snap;
|
||||||
|
GridChangeNotify();
|
||||||
|
}
|
||||||
|
|
||||||
void Grid_registerCommands()
|
void Grid_registerCommands()
|
||||||
{
|
{
|
||||||
GlobalCommands_insert("GridDown", FreeCaller<GridPrev>(), Accelerator('['));
|
GlobalCommands_insert("GridDown", FreeCaller<GridPrev>(), Accelerator('['));
|
||||||
GlobalCommands_insert("GridUp", FreeCaller<GridNext>(), Accelerator(']'));
|
GlobalCommands_insert("GridUp", FreeCaller<GridNext>(), Accelerator(']'));
|
||||||
|
|
||||||
|
GlobalCommands_insert("ToggleGridSnap", FreeCaller<ToggleGridSnap>());
|
||||||
|
|
||||||
GlobalToggles_insert("SetGrid0.125", GridMenuItem::SetCaller(g_gridMenu0125), ToggleItem::AddCallbackCaller(g_gridMenu0125.m_item));
|
GlobalToggles_insert("SetGrid0.125", GridMenuItem::SetCaller(g_gridMenu0125), ToggleItem::AddCallbackCaller(g_gridMenu0125.m_item));
|
||||||
GlobalToggles_insert("SetGrid0.25", GridMenuItem::SetCaller(g_gridMenu025), ToggleItem::AddCallbackCaller(g_gridMenu025.m_item));
|
GlobalToggles_insert("SetGrid0.25", GridMenuItem::SetCaller(g_gridMenu025), ToggleItem::AddCallbackCaller(g_gridMenu025.m_item));
|
||||||
GlobalToggles_insert("SetGrid0.5", GridMenuItem::SetCaller(g_gridMenu05), ToggleItem::AddCallbackCaller(g_gridMenu05.m_item));
|
GlobalToggles_insert("SetGrid0.5", GridMenuItem::SetCaller(g_gridMenu05), ToggleItem::AddCallbackCaller(g_gridMenu05.m_item));
|
||||||
|
|
@ -234,6 +251,7 @@ void Grid_registerShortcuts()
|
||||||
command_connect_accelerator("ToggleGrid");
|
command_connect_accelerator("ToggleGrid");
|
||||||
command_connect_accelerator("GridDown");
|
command_connect_accelerator("GridDown");
|
||||||
command_connect_accelerator("GridUp");
|
command_connect_accelerator("GridUp");
|
||||||
|
command_connect_accelerator("ToggleGridSnap");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Grid_constructPreferences(PreferencesPage& page)
|
void Grid_constructPreferences(PreferencesPage& page)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "signal/signalfwd.h"
|
#include "signal/signalfwd.h"
|
||||||
|
|
||||||
|
float GetSnapGridSize();
|
||||||
float GetGridSize();
|
float GetGridSize();
|
||||||
int Grid_getPower();
|
int Grid_getPower();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -718,7 +718,7 @@ void PasteToCamera()
|
||||||
// Work out the delta
|
// Work out the delta
|
||||||
Vector3 mid;
|
Vector3 mid;
|
||||||
Select_GetMid(mid);
|
Select_GetMid(mid);
|
||||||
Vector3 delta = vector3_subtracted(vector3_snapped(Camera_getOrigin(camwnd), GetGridSize()), mid);
|
Vector3 delta = vector3_subtracted(vector3_snapped(Camera_getOrigin(camwnd), GetSnapGridSize()), mid);
|
||||||
|
|
||||||
// Move to camera
|
// Move to camera
|
||||||
GlobalSelectionSystem().translateSelected(delta);
|
GlobalSelectionSystem().translateSelected(delta);
|
||||||
|
|
@ -3288,7 +3288,7 @@ void MainFrame::SetGridStatus()
|
||||||
{
|
{
|
||||||
StringOutputStream status(64);
|
StringOutputStream status(64);
|
||||||
const char* lock = (GridStatus_getTextureLockEnabled()) ? "ON" : "OFF";
|
const char* lock = (GridStatus_getTextureLockEnabled()) ? "ON" : "OFF";
|
||||||
status << "G:" << GridStatus_getGridSize()
|
status << (GetSnapGridSize() > 0 ? "G:" : "g:") << GridStatus_getGridSize()
|
||||||
<< " R:" << GridStatus_getRotateIncrement()
|
<< " R:" << GridStatus_getRotateIncrement()
|
||||||
<< " C:" << GridStatus_getFarClipDistance()
|
<< " C:" << GridStatus_getFarClipDistance()
|
||||||
<< " L:" << lock;
|
<< " L:" << lock;
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ public:
|
||||||
current = vector3_scaled(m_axis, distance_for_axis(m_start, current, m_axis));
|
current = vector3_scaled(m_axis, distance_for_axis(m_start, current, m_axis));
|
||||||
|
|
||||||
translation_local2object(current, current, manip2object);
|
translation_local2object(current, current, manip2object);
|
||||||
vector3_snap(current, GetGridSize());
|
vector3_snap(current, GetSnapGridSize());
|
||||||
|
|
||||||
m_translatable.translate(current);
|
m_translatable.translate(current);
|
||||||
}
|
}
|
||||||
|
|
@ -350,7 +350,7 @@ public:
|
||||||
current = vector3_subtracted(current, m_start);
|
current = vector3_subtracted(current, m_start);
|
||||||
|
|
||||||
translation_local2object(current, current, manip2object);
|
translation_local2object(current, current, manip2object);
|
||||||
vector3_snap(current, GetGridSize());
|
vector3_snap(current, GetSnapGridSize());
|
||||||
|
|
||||||
m_translatable.translate(current);
|
m_translatable.translate(current);
|
||||||
}
|
}
|
||||||
|
|
@ -386,9 +386,9 @@ public:
|
||||||
Vector3 delta = vector3_subtracted(current, m_start);
|
Vector3 delta = vector3_subtracted(current, m_start);
|
||||||
|
|
||||||
translation_local2object(delta, delta, manip2object);
|
translation_local2object(delta, delta, manip2object);
|
||||||
vector3_snap(delta, GetGridSize());
|
vector3_snap(delta, GetSnapGridSize());
|
||||||
|
|
||||||
Vector3 start(vector3_snapped(m_start, GetGridSize()));
|
Vector3 start(vector3_snapped(m_start, GetSnapGridSize()));
|
||||||
Vector3 scale(
|
Vector3 scale(
|
||||||
start[0] == 0 ? 1 : 1 + delta[0] / start[0],
|
start[0] == 0 ? 1 : 1 + delta[0] / start[0],
|
||||||
start[1] == 0 ? 1 : 1 + delta[1] / start[1],
|
start[1] == 0 ? 1 : 1 + delta[1] / start[1],
|
||||||
|
|
@ -424,9 +424,9 @@ public:
|
||||||
Vector3 delta = vector3_subtracted(current, m_start);
|
Vector3 delta = vector3_subtracted(current, m_start);
|
||||||
|
|
||||||
translation_local2object(delta, delta, manip2object);
|
translation_local2object(delta, delta, manip2object);
|
||||||
vector3_snap(delta, GetGridSize());
|
vector3_snap(delta, GetSnapGridSize());
|
||||||
|
|
||||||
Vector3 start(vector3_snapped(m_start, GetGridSize()));
|
Vector3 start(vector3_snapped(m_start, GetSnapGridSize()));
|
||||||
Vector3 scale(
|
Vector3 scale(
|
||||||
start[0] == 0 ? 1 : 1 + delta[0] / start[0],
|
start[0] == 0 ? 1 : 1 + delta[0] / start[0],
|
||||||
start[1] == 0 ? 1 : 1 + delta[1] / start[1],
|
start[1] == 0 ? 1 : 1 + delta[1] / start[1],
|
||||||
|
|
@ -3730,7 +3730,7 @@ void RadiantSelectionSystem::ConstructPivot() const
|
||||||
m_object_pivot = bounds.origin;
|
m_object_pivot = bounds.origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector3_snap(m_object_pivot, GetGridSize());
|
vector3_snap(m_object_pivot, GetSnapGridSize());
|
||||||
m_pivot2world = matrix4_translation_for_vec3(m_object_pivot);
|
m_pivot2world = matrix4_translation_for_vec3(m_object_pivot);
|
||||||
|
|
||||||
switch(m_manipulator_mode)
|
switch(m_manipulator_mode)
|
||||||
|
|
|
||||||
|
|
@ -966,7 +966,7 @@ void XYWnd::DropClipPoint(int pointx, int pointy)
|
||||||
g_clip_viewtype = static_cast<VIEWTYPE>(GetViewType());
|
g_clip_viewtype = static_cast<VIEWTYPE>(GetViewType());
|
||||||
const int nDim = (g_clip_viewtype == YZ ) ? 0 : ( (g_clip_viewtype == XZ) ? 1 : 2 );
|
const int nDim = (g_clip_viewtype == YZ ) ? 0 : ( (g_clip_viewtype == XZ) ? 1 : 2 );
|
||||||
point[nDim] = mid[nDim];
|
point[nDim] = mid[nDim];
|
||||||
vector3_snap(point, GetGridSize());
|
vector3_snap(point, GetSnapGridSize());
|
||||||
NewClipPoint(point);
|
NewClipPoint(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1093,8 +1093,8 @@ void XYWnd::NewBrushDrag(int x, int y)
|
||||||
|
|
||||||
int nDim = (m_viewType == XY) ? 2 : (m_viewType == YZ) ? 0 : 1;
|
int nDim = (m_viewType == XY) ? 2 : (m_viewType == YZ) ? 0 : 1;
|
||||||
|
|
||||||
mins[nDim] = float_snapped(Select_getWorkZone().d_work_min[nDim], GetGridSize());
|
mins[nDim] = float_snapped(Select_getWorkZone().d_work_min[nDim], GetSnapGridSize());
|
||||||
maxs[nDim] = float_snapped(Select_getWorkZone().d_work_max[nDim], GetGridSize());
|
maxs[nDim] = float_snapped(Select_getWorkZone().d_work_max[nDim], GetSnapGridSize());
|
||||||
|
|
||||||
if (maxs[nDim] <= mins[nDim])
|
if (maxs[nDim] <= mins[nDim])
|
||||||
maxs[nDim] = mins[nDim] + GetGridSize();
|
maxs[nDim] = mins[nDim] + GetGridSize();
|
||||||
|
|
@ -1555,18 +1555,18 @@ void XYWnd::XY_SnapToGrid(Vector3& point)
|
||||||
{
|
{
|
||||||
if (m_viewType == XY)
|
if (m_viewType == XY)
|
||||||
{
|
{
|
||||||
point[0] = float_snapped(point[0], GetGridSize());
|
point[0] = float_snapped(point[0], GetSnapGridSize());
|
||||||
point[1] = float_snapped(point[1], GetGridSize());
|
point[1] = float_snapped(point[1], GetSnapGridSize());
|
||||||
}
|
}
|
||||||
else if (m_viewType == YZ)
|
else if (m_viewType == YZ)
|
||||||
{
|
{
|
||||||
point[1] = float_snapped(point[1], GetGridSize());
|
point[1] = float_snapped(point[1], GetSnapGridSize());
|
||||||
point[2] = float_snapped(point[2], GetGridSize());
|
point[2] = float_snapped(point[2], GetSnapGridSize());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
point[0] = float_snapped(point[0], GetGridSize());
|
point[0] = float_snapped(point[0], GetSnapGridSize());
|
||||||
point[2] = float_snapped(point[2], GetGridSize());
|
point[2] = float_snapped(point[2], GetSnapGridSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1701,10 +1701,9 @@ void LightWorld( void )
|
||||||
SetupEnvelopes( qtrue, fastgrid );
|
SetupEnvelopes( qtrue, fastgrid );
|
||||||
|
|
||||||
Sys_Printf( "--- TraceGrid ---\n" );
|
Sys_Printf( "--- TraceGrid ---\n" );
|
||||||
ps = patchShadows;
|
inGrid = qtrue;
|
||||||
patchShadows = qfalse; /* patch shadows + lightgrid sampling tends to sample between patch and caulk, so let's turn that off for now FIXME */
|
|
||||||
RunThreadsOnIndividual( numRawGridPoints, qtrue, TraceGrid );
|
RunThreadsOnIndividual( numRawGridPoints, qtrue, TraceGrid );
|
||||||
patchShadows = ps;
|
inGrid = qfalse;
|
||||||
Sys_Printf( "%d x %d x %d = %d grid\n",
|
Sys_Printf( "%d x %d x %d = %d grid\n",
|
||||||
gridBounds[ 0 ], gridBounds[ 1 ], gridBounds[ 2 ], numBSPGridPoints );
|
gridBounds[ 0 ], gridBounds[ 1 ], gridBounds[ 2 ], numBSPGridPoints );
|
||||||
|
|
||||||
|
|
@ -1800,10 +1799,9 @@ void LightWorld( void )
|
||||||
gridBoundsCulled = 0;
|
gridBoundsCulled = 0;
|
||||||
|
|
||||||
Sys_Printf( "--- BounceGrid ---\n" );
|
Sys_Printf( "--- BounceGrid ---\n" );
|
||||||
ps = patchShadows;
|
inGrid = qtrue;
|
||||||
patchShadows = qfalse; /* patch shadows + lightgrid sampling tends to sample between patch and caulk, so let's turn that off for now FIXME */
|
|
||||||
RunThreadsOnIndividual( numRawGridPoints, qtrue, TraceGrid );
|
RunThreadsOnIndividual( numRawGridPoints, qtrue, TraceGrid );
|
||||||
patchShadows = ps;
|
inGrid = qfalse;
|
||||||
Sys_FPrintf( SYS_VRB, "%9d grid points envelope culled\n", gridEnvelopeCulled );
|
Sys_FPrintf( SYS_VRB, "%9d grid points envelope culled\n", gridEnvelopeCulled );
|
||||||
Sys_FPrintf( SYS_VRB, "%9d grid points bounds culled\n", gridBoundsCulled );
|
Sys_FPrintf( SYS_VRB, "%9d grid points bounds culled\n", gridBoundsCulled );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ traceVert_t;
|
||||||
typedef struct traceInfo_s
|
typedef struct traceInfo_s
|
||||||
{
|
{
|
||||||
shaderInfo_t *si;
|
shaderInfo_t *si;
|
||||||
int surfaceNum, castShadows;
|
int surfaceNum, castShadows, skipGrid;
|
||||||
}
|
}
|
||||||
traceInfo_t;
|
traceInfo_t;
|
||||||
|
|
||||||
|
|
@ -144,7 +144,8 @@ static int AddTraceInfo( traceInfo_t *ti )
|
||||||
{
|
{
|
||||||
if( traceInfos[ num ].si == ti->si &&
|
if( traceInfos[ num ].si == ti->si &&
|
||||||
traceInfos[ num ].surfaceNum == ti->surfaceNum &&
|
traceInfos[ num ].surfaceNum == ti->surfaceNum &&
|
||||||
traceInfos[ num ].castShadows == ti->castShadows )
|
traceInfos[ num ].castShadows == ti->castShadows &&
|
||||||
|
traceInfos[ num ].skipGrid == ti->skipGrid )
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -974,6 +975,7 @@ static void PopulateWithBSPModel( bspModel_t *model, m4x4_t transform )
|
||||||
ti.si = info->si;
|
ti.si = info->si;
|
||||||
ti.castShadows = info->castShadows;
|
ti.castShadows = info->castShadows;
|
||||||
ti.surfaceNum = model->firstBSPBrush + i;
|
ti.surfaceNum = model->firstBSPBrush + i;
|
||||||
|
ti.skipGrid = (ds->surfaceType == MST_PATCH);
|
||||||
|
|
||||||
/* choose which node (normal or skybox) */
|
/* choose which node (normal or skybox) */
|
||||||
if( info->parentSurfaceNum >= 0 )
|
if( info->parentSurfaceNum >= 0 )
|
||||||
|
|
@ -1143,6 +1145,7 @@ static void PopulateWithPicoModel( int castShadows, picoModel_t *model, m4x4_t t
|
||||||
/* setup trace info */
|
/* setup trace info */
|
||||||
ti.castShadows = castShadows;
|
ti.castShadows = castShadows;
|
||||||
ti.surfaceNum = -1;
|
ti.surfaceNum = -1;
|
||||||
|
ti.skipGrid = qtrue; // also ignore picomodels when skipping patches
|
||||||
|
|
||||||
/* setup trace winding */
|
/* setup trace winding */
|
||||||
memset( &tw, 0, sizeof( tw ) );
|
memset( &tw, 0, sizeof( tw ) );
|
||||||
|
|
@ -1426,7 +1429,7 @@ qboolean TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace )
|
||||||
if( ti->castShadows != 1 )
|
if( ti->castShadows != 1 )
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* receive shadows from same group and worldspawn group */
|
/* receive shadows from same group and worldspawn group */
|
||||||
else if( trace->recvShadows > 1 )
|
else if( trace->recvShadows > 1 )
|
||||||
{
|
{
|
||||||
|
|
@ -1442,6 +1445,13 @@ qboolean TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace )
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* skip patches when doing the grid (FIXME this is an ugly hack) */
|
||||||
|
if( inGrid )
|
||||||
|
{
|
||||||
|
if (ti->skipGrid)
|
||||||
|
return qfalse;
|
||||||
|
}
|
||||||
|
|
||||||
/* begin calculating determinant - also used to calculate u parameter */
|
/* begin calculating determinant - also used to calculate u parameter */
|
||||||
CrossProduct( trace->direction, tt->edge2, pvec );
|
CrossProduct( trace->direction, tt->edge2, pvec );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2223,6 +2223,7 @@ Q_EXTERN float gridScale Q_ASSIGN( 1.0f );
|
||||||
Q_EXTERN float gridAmbientScale Q_ASSIGN( 1.0f );
|
Q_EXTERN float gridAmbientScale Q_ASSIGN( 1.0f );
|
||||||
Q_EXTERN float gridDirectionality Q_ASSIGN( 1.0f );
|
Q_EXTERN float gridDirectionality Q_ASSIGN( 1.0f );
|
||||||
Q_EXTERN float gridAmbientDirectionality Q_ASSIGN( 0.0f );
|
Q_EXTERN float gridAmbientDirectionality Q_ASSIGN( 0.0f );
|
||||||
|
Q_EXTERN qboolean inGrid Q_ASSIGN(0);
|
||||||
|
|
||||||
/* ydnar: lightmap gamma/compensation */
|
/* ydnar: lightmap gamma/compensation */
|
||||||
Q_EXTERN float lightmapGamma Q_ASSIGN( 1.0f );
|
Q_EXTERN float lightmapGamma Q_ASSIGN( 1.0f );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user