From 2e58d1616412859c61ca95f9e7b6b7ce65fe6440 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 27 Aug 2011 17:08:46 +0200 Subject: [PATCH 1/9] update gitattributes --- .gitattributes | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/.gitattributes b/.gitattributes index ec3bfe3d..bf8bf302 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,4 @@ * -crlf - *.0 -diff -crlf *.1 crlf=input *.3 crlf=input @@ -27,7 +26,7 @@ branch-manager crlf=input BSDmakefile crlf=input bsp2ent crlf=input *.bsp -diff -crlf -*.cache -diff -crlf +*.cache crlf=input *.cbp -crlf *.cbp -diff -crlf *.c crlf=input @@ -44,15 +43,20 @@ COPYING crlf=input *.cpp crlf=input create crlf=input *.cron crlf=input +crypto-keygen-standalone -diff -crlf *.css crlf=input *.cvswrappers crlf=input +*.d0ir crlf=input *.d0pk -diff -crlf -*.db -diff -crlf +*.db crlf=input +*.db.* crlf=input +*.def2ent crlf=input *.default crlf=input *.def crlf=input *.dem -diff -crlf *.dev -crlf dir -diff -crlf +*.directory crlf=input djpeg -diff -crlf *.dll -diff -crlf DOCS -diff -crlf @@ -68,9 +72,13 @@ Doxyfile crlf=input *.dylib -diff -crlf empty -diff -crlf *.EncoderPlugin crlf=input +*.ent crlf=input +etc_svc_git-daemon_run crlf=input *.flac -diff -crlf +*.flp -diff -crlf *.form crlf=input *.framegroups crlf=input +*.fteqccfail -diff -crlf *.game crlf=input *.gdb crlf=input gendox crlf=input @@ -92,10 +100,13 @@ git-svn-update crlf=input git-update-octopus crlf=input *.glp crlf=input *.glsl crlf=input +GPL-2 crlf=input +GPL-3 crlf=input GPL crlf=input *.hardwired crlf=input *.h crlf=input *.hs crlf=input +*.htaccess crlf=input *.html crlf=input *.html-part crlf=input *.icns -diff -crlf @@ -108,7 +119,7 @@ GPL crlf=input *.info-2 -diff -crlf *.info -diff -crlf *.inl crlf=input -*.instantaction crlf=input +*.iOS crlf=input *.iqm -diff -crlf *.java crlf=input *.jhm crlf=input @@ -140,25 +151,31 @@ makespr32 crlf=input *.mkdir -diff -crlf *.mmpz -diff -crlf *.modules crlf=input +*.mp3 -diff -crlf *.nib -crlf *.obj -crlf OFFSETS -diff -crlf *.ogg -diff -crlf *.options crlf=input +*.otf -diff -crlf pangorc crlf=input +*.part crlf=input *.patch crlf=input *.patchsets crlf=input +*.pbxproj crlf=input *.pc crlf=input -*.pcx -diff -crlf *.pfb -diff -crlf *.pfm -diff -crlf +*.php crlf=input *.pk3 -diff -crlf PkgInfo crlf=input *.pl crlf=input *.plist crlf=input *.pm crlf=input *.png -diff -crlf +*.po crlf=input POSITIONS -diff -crlf +*.pot crlf=input *.proj -crlf *.properties crlf=input *.psd -diff -crlf @@ -167,17 +184,19 @@ POSITIONS -diff -crlf *.qc crlf=input *.qdt crlf=input *.qh crlf=input +*.rar -diff -crlf *.rb crlf=input *.rc2 crlf=input *.rc -crlf rdjpgcom -diff -crlf *.readme crlf=input README crlf=input -*.rtlights -diff -crlf +*.rtlights crlf=input SCHEMA crlf=input *.scm crlf=input sdl-config crlf=input SDL -diff -crlf +*.sfd -diff -crlf *.shader crlf=input *.sh crlf=input *.skin crlf=input @@ -196,15 +215,16 @@ TMAP -diff -crlf todo crlf=input TODO crlf=input *.ttf -diff -crlf -*.TTF -diff -crlf *.txt crlf=input +*.txt.* crlf=input update-shaderlists crlf=input *.vbs -crlf *.vcproj -crlf +*.vcxproj crlf=input versionbuilder crlf=input +*.vhost crlf=input *.wav -diff -crlf -*.waypoints -diff -crlf -w crlf=input +*.waypoints crlf=input *.width crlf=input *.workspace -crlf wrjpgcom -diff -crlf @@ -214,9 +234,9 @@ wrjpgcom -diff -crlf xonotic-map-compiler-autobuild crlf=input xonotic-map-compiler crlf=input xonotic-map-screenshot crlf=input -xonotic-osx-agl crlf=input xonotic-osx-sdl crlf=input *.xpm crlf=input +*.xrns -diff -crlf *.zip -diff -crlf zipdiff crlf=input *.zym -diff -crlf From 33885f370cb90a1f3e9e4e2237364b1bf5c56fa0 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 15 Sep 2011 17:21:40 +0200 Subject: [PATCH 2/9] fix MAX_BBOX_DISTANCE path (not enabled) --- tools/quake3/q3map2/surface_meta.c | 38 ++++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index 8a684855..7bdeecc5 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -1399,6 +1399,9 @@ returns the score of the triangle added static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, qboolean testAdd ) { +#if MAX_BBOX_DISTANCE > 0 + vec3_t p; +#endif int i, score, coincident, ai, bi, ci, oldTexRange[ 2 ]; float lmMax; vec3_t mins, maxs; @@ -1433,30 +1436,35 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, return 0; } + + #if MAX_BBOX_DISTANCE > 0 - VectorCopy( ds->mins, mins ); - VectorCopy( ds->maxs, maxs ); - mins[0] -= MAX_BBOX_DISTANCE; - mins[1] -= MAX_BBOX_DISTANCE; - mins[2] -= MAX_BBOX_DISTANCE; - maxs[0] += MAX_BBOX_DISTANCE; - maxs[1] += MAX_BBOX_DISTANCE; - maxs[2] += MAX_BBOX_DISTANCE; + if(ds->numIndexes > 0) + { + VectorCopy( ds->mins, mins ); + VectorCopy( ds->maxs, maxs ); + mins[0] -= MAX_BBOX_DISTANCE; + mins[1] -= MAX_BBOX_DISTANCE; + mins[2] -= MAX_BBOX_DISTANCE; + maxs[0] += MAX_BBOX_DISTANCE; + maxs[1] += MAX_BBOX_DISTANCE; + maxs[2] += MAX_BBOX_DISTANCE; #define CHECK_1D(mins, v, maxs) ((mins) <= (v) && (v) <= (maxs)) #define CHECK_3D(mins, v, maxs) (CHECK_1D((mins)[0], (v)[0], (maxs)[0]) && CHECK_1D((mins)[1], (v)[1], (maxs)[1]) && CHECK_1D((mins)[2], (v)[2], (maxs)[2])) - VectorCopy(metaVerts[ tri->indexes[ 0 ] ].xyz, p); - if(!CHECK_3D(mins, p, maxs)) - { - VectorCopy(metaVerts[ tri->indexes[ 1 ] ].xyz, p); + VectorCopy(metaVerts[ tri->indexes[ 0 ] ].xyz, p); if(!CHECK_3D(mins, p, maxs)) { - VectorCopy(metaVerts[ tri->indexes[ 2 ] ].xyz, p); + VectorCopy(metaVerts[ tri->indexes[ 1 ] ].xyz, p); if(!CHECK_3D(mins, p, maxs)) - return 0; + { + VectorCopy(metaVerts[ tri->indexes[ 2 ] ].xyz, p); + if(!CHECK_3D(mins, p, maxs)) + return 0; + } } - } #undef CHECK_3D #undef CHECK_1D + } #endif /* set initial score */ From 9aa6996229ce0872d7e694e928339fee05c952e1 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 15 Sep 2011 21:19:39 +0200 Subject: [PATCH 3/9] make runtime parameters for meta --- tools/quake3/q3map2/bsp.c | 27 ++++++++++++++++ tools/quake3/q3map2/q3map2.h | 3 ++ tools/quake3/q3map2/surface_meta.c | 51 +++++++++++++++--------------- 3 files changed, 56 insertions(+), 25 deletions(-) diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index 79019792..414b92ad 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -856,6 +856,33 @@ int BSPMain( int argc, char **argv ) Sys_Printf( "Creating meta surfaces from brush faces\n" ); meta = qtrue; } + else if( !strcmp( argv[ i ], "-metaadequatescore" ) ) + { + metaAdequateScore = atoi( argv[ i + 1 ]); + if( metaAdequateScore < 0 ) + metaAdequateScore = -1; + i++; + if( metaAdequateScore >= 0 ) + Sys_Printf( "Setting ADEQUATE meta score to %d (see surface_meta.c)\n", metaGoodScore ); + } + else if( !strcmp( argv[ i ], "-metagoodscore" ) ) + { + metaGoodScore = atoi( argv[ i + 1 ]); + if( metaGoodScore < 0 ) + metaGoodScore = -1; + i++; + if( metaGoodScore >= 0 ) + Sys_Printf( "Setting GOOD meta score to %d (see surface_meta.c)\n", metaGoodScore ); + } + else if( !strcmp( argv[ i ], "-metamaxbboxdistance" ) ) + { + metaMaxBBoxDistance = atof( argv[ i + 1 ]); + if( metaMaxBBoxDistance < 0 ) + metaMaxBBoxDistance = -1; + i++; + if( metaMaxBBoxDistance >= 0 ) + Sys_Printf( "Setting meta maximum bounding box distance to %f\n", metaMaxBBoxDistance ); + } else if( !strcmp( argv[ i ], "-patchmeta" ) ) { Sys_Printf( "Creating meta surfaces from patches\n" ); diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index e912d15b..ce6367f2 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -2034,6 +2034,9 @@ Q_EXTERN qboolean debugPortals Q_ASSIGN( qfalse ); Q_EXTERN qboolean lightmapTriangleCheck Q_ASSIGN(qfalse); Q_EXTERN qboolean lightmapExtraVisClusterNudge Q_ASSIGN(qfalse); Q_EXTERN qboolean lightmapFill Q_ASSIGN(qfalse); +Q_EXTERN int metaAdequateScore Q_ASSIGN( -1 ); +Q_EXTERN int metaGoodScore Q_ASSIGN( -1 ); +Q_EXTERN float metaMaxBBoxDistance Q_ASSIGN( -1 ); #if Q3MAP2_EXPERIMENTAL_SNAP_NORMAL_FIX // Increasing the normalEpsilon to compensate for new logic in SnapNormal(), where diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index 7bdeecc5..7f7d0b74 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -1388,20 +1388,20 @@ returns the score of the triangle added #define AXIS_SCORE 100000 #define AXIS_MIN 100000 #define VERT_SCORE 10000 -#define SURFACE_SCORE 1000 +#define SURFACE_SCORE 1000 #define ST_SCORE 50 #define ST_SCORE2 (2 * (ST_SCORE)) -#define ADEQUATE_SCORE ((AXIS_MIN) + 1 * (VERT_SCORE)) -#define GOOD_SCORE ((AXIS_MIN) + 2 * (VERT_SCORE) + 4 * (ST_SCORE)) -#define PERFECT_SCORE ((AXIS_MIN) + 3 * (VERT_SCORE) + (SURFACE_SCORE) + 4 * (ST_SCORE)) -//#define MAX_BBOX_DISTANCE 16 +#define DEFAULT_ADEQUATE_SCORE ((AXIS_MIN) + 1 * (VERT_SCORE)) +#define DEFAULT_GOOD_SCORE ((AXIS_MIN) + 2 * (VERT_SCORE) + 4 * (ST_SCORE)) +#define PERFECT_SCORE ((AXIS_MIN) + 3 * (VERT_SCORE) + (SURFACE_SCORE) + 4 * (ST_SCORE)) + +#define ADEQUATE_SCORE (metaAdequateScore >= 0 ? metaAdequateScore : DEFAULT_ADEQUATE_SCORE) +#define GOOD_SCORE (metaGoodScore >= 0 ? metaGoodScore : DEFAULT_GOOD_SCORE) static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, qboolean testAdd ) { -#if MAX_BBOX_DISTANCE > 0 vec3_t p; -#endif int i, score, coincident, ai, bi, ci, oldTexRange[ 2 ]; float lmMax; vec3_t mins, maxs; @@ -1438,34 +1438,35 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, -#if MAX_BBOX_DISTANCE > 0 - if(ds->numIndexes > 0) + if(metaMaxBBoxDistance >= 0) { - VectorCopy( ds->mins, mins ); - VectorCopy( ds->maxs, maxs ); - mins[0] -= MAX_BBOX_DISTANCE; - mins[1] -= MAX_BBOX_DISTANCE; - mins[2] -= MAX_BBOX_DISTANCE; - maxs[0] += MAX_BBOX_DISTANCE; - maxs[1] += MAX_BBOX_DISTANCE; - maxs[2] += MAX_BBOX_DISTANCE; + if(ds->numIndexes > 0) + { + VectorCopy( ds->mins, mins ); + VectorCopy( ds->maxs, maxs ); + mins[0] -= metaMaxBBoxDistance; + mins[1] -= metaMaxBBoxDistance; + mins[2] -= metaMaxBBoxDistance; + maxs[0] += metaMaxBBoxDistance; + maxs[1] += metaMaxBBoxDistance; + maxs[2] += metaMaxBBoxDistance; #define CHECK_1D(mins, v, maxs) ((mins) <= (v) && (v) <= (maxs)) #define CHECK_3D(mins, v, maxs) (CHECK_1D((mins)[0], (v)[0], (maxs)[0]) && CHECK_1D((mins)[1], (v)[1], (maxs)[1]) && CHECK_1D((mins)[2], (v)[2], (maxs)[2])) - VectorCopy(metaVerts[ tri->indexes[ 0 ] ].xyz, p); - if(!CHECK_3D(mins, p, maxs)) - { - VectorCopy(metaVerts[ tri->indexes[ 1 ] ].xyz, p); + VectorCopy(metaVerts[ tri->indexes[ 0 ] ].xyz, p); if(!CHECK_3D(mins, p, maxs)) { - VectorCopy(metaVerts[ tri->indexes[ 2 ] ].xyz, p); + VectorCopy(metaVerts[ tri->indexes[ 1 ] ].xyz, p); if(!CHECK_3D(mins, p, maxs)) - return 0; + { + VectorCopy(metaVerts[ tri->indexes[ 2 ] ].xyz, p); + if(!CHECK_3D(mins, p, maxs)) + return 0; + } } - } #undef CHECK_3D #undef CHECK_1D + } } -#endif /* set initial score */ score = tri->surfaceNum == ds->surfaceNum ? SURFACE_SCORE : 0; From 778563508dd51f2251355a57d9e063f467b1fbc7 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 16 Sep 2011 06:55:21 +0200 Subject: [PATCH 4/9] fix two obvious typos --- tools/quake3/q3map2/bsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index 414b92ad..54e14bf1 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -810,7 +810,7 @@ int BSPMain( int argc, char **argv ) { npDegrees = atof( argv[ i + 1 ] ); if( npDegrees < 0.0f ) - shadeAngleDegrees = 0.0f; + npDegrees = 0.0f; else if( npDegrees > 0.0f ) Sys_Printf( "Forcing nonplanar surfaces with a breaking angle of %f degrees\n", npDegrees ); i++; @@ -863,7 +863,7 @@ int BSPMain( int argc, char **argv ) metaAdequateScore = -1; i++; if( metaAdequateScore >= 0 ) - Sys_Printf( "Setting ADEQUATE meta score to %d (see surface_meta.c)\n", metaGoodScore ); + Sys_Printf( "Setting ADEQUATE meta score to %d (see surface_meta.c)\n", metaAdequateScore ); } else if( !strcmp( argv[ i ], "-metagoodscore" ) ) { From 9c436e5a25c6d9674a1b3568ee622ed1b3b7880b Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 1 Oct 2011 22:10:43 +0200 Subject: [PATCH 5/9] why was this commented out - broke modelscale --- radiant/renderstate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radiant/renderstate.cpp b/radiant/renderstate.cpp index 2f5596d1..2ec1f7b6 100644 --- a/radiant/renderstate.cpp +++ b/radiant/renderstate.cpp @@ -1827,7 +1827,7 @@ void OpenGLState_apply(const OpenGLState& self, OpenGLState& current, unsigned i { glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); - //qglEnable(GL_RESCALE_NORMAL); + glEnable(GL_RESCALE_NORMAL); glEnableClientState(GL_NORMAL_ARRAY); GlobalOpenGL_debugAssertNoErrors(); g_normalArray_enabled = true; @@ -1836,7 +1836,7 @@ void OpenGLState_apply(const OpenGLState& self, OpenGLState& current, unsigned i { glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); - //qglDisable(GL_RESCALE_NORMAL); + glDisable(GL_RESCALE_NORMAL); glDisableClientState(GL_NORMAL_ARRAY); GlobalOpenGL_debugAssertNoErrors(); g_normalArray_enabled = false; From 66cbc01bb8a5c4962df2a447836841d90329ea29 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 7 Oct 2011 11:56:48 +0200 Subject: [PATCH 6/9] Experimental: add "XactCylinder" to make a better patch cylinder --- radiant/patch.cpp | 27 +++++++++++++++++++++++++++ radiant/patch.h | 1 + radiant/patchmanip.cpp | 9 +++++++++ 3 files changed, 37 insertions(+) diff --git a/radiant/patch.cpp b/radiant/patch.cpp index ac96240f..221d3333 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -1400,6 +1400,33 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: return; } } + else if (eType == eXactCylinder) + { + int n = 6; // n = number of segments + setDims(2 * n + 1, 3); + + // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents); + // vPos[1] = aabb.origin; + // vPos[2] = vector3_added(aabb.origin, aabb.extents); + + int i, j; + float f = 1 / cos(M_PI / n); + for(i = 0; i < 2*n+1; ++i) + { + float angle = (M_PI * i) / n; + float x = vPos[1][0] + cos(angle) * (vPos[2][0] - vPos[1][0]) * ((i&1) ? f : 1.0f); + float y = vPos[1][1] + sin(angle) * (vPos[2][1] - vPos[1][1]) * ((i&1) ? f : 1.0f); + for(j = 0; j < 3; ++j) + { + float z = vPos[j][2]; + PatchControl *v; + v = &m_ctrl.data()[j*(2*n+1)+i]; + v->m_vertex[0] = x; + v->m_vertex[1] = y; + v->m_vertex[2] = z; + } + } + } else if (eType == eBevel) { unsigned char *pIndex; diff --git a/radiant/patch.h b/radiant/patch.h index d55e712b..61ecba9b 100644 --- a/radiant/patch.h +++ b/radiant/patch.h @@ -102,6 +102,7 @@ enum EPatchPrefab eSqCylinder, eCone, eSphere, + eXactCylinder, }; enum EMatrixMajor diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index b8bccee6..46818cf0 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -432,6 +432,13 @@ AABB PatchCreator_getBounds() return AABB(Vector3(0, 0, 0), Vector3(64, 64, 64)); } +void Patch_XactCylinder() +{ + UndoableCommand undo("patchCreateXactCylinder"); + + Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eXactCylinder, GlobalXYWnd_getCurrentViewType()); +} + void Patch_Cylinder() { UndoableCommand undo("patchCreateCylinder"); @@ -743,6 +750,7 @@ void Patch_registerCommands() GlobalCommands_insert("DecPatchRow", FreeCaller(), Accelerator(GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK)); GlobalCommands_insert("NaturalizePatch", FreeCaller(), Accelerator('N', (GdkModifierType)GDK_CONTROL_MASK)); GlobalCommands_insert("PatchCylinder", FreeCaller()); + GlobalCommands_insert("PatchXactCylinder", FreeCaller()); GlobalCommands_insert("PatchDenseCylinder", FreeCaller()); GlobalCommands_insert("PatchVeryDenseCylinder", FreeCaller()); GlobalCommands_insert("PatchSquareCylinder", FreeCaller()); @@ -788,6 +796,7 @@ void Patch_constructMenu(GtkMenu* menu) create_menu_item_with_mnemonic(menu_in_menu, "Dense Cylinder", "PatchDenseCylinder"); create_menu_item_with_mnemonic(menu_in_menu, "Very Dense Cylinder", "PatchVeryDenseCylinder"); create_menu_item_with_mnemonic(menu_in_menu, "Square Cylinder", "PatchSquareCylinder"); + create_menu_item_with_mnemonic(menu_in_menu, "Exact Cylinder", "PatchXactCylinder"); } menu_separator (menu); create_menu_item_with_mnemonic(menu, "End cap", "PatchEndCap"); From bf8fb3fc0bc85d920581ef874d411a5dafb99666 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 7 Oct 2011 12:15:18 +0200 Subject: [PATCH 7/9] also support XactCone and XactSphere --- radiant/patch.cpp | 63 ++++++++++++++++++++++++++++++++++++++++-- radiant/patch.h | 2 ++ radiant/patchmanip.cpp | 23 +++++++++++++-- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 221d3333..9ecb6499 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -1413,9 +1413,9 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: float f = 1 / cos(M_PI / n); for(i = 0; i < 2*n+1; ++i) { - float angle = (M_PI * i) / n; - float x = vPos[1][0] + cos(angle) * (vPos[2][0] - vPos[1][0]) * ((i&1) ? f : 1.0f); - float y = vPos[1][1] + sin(angle) * (vPos[2][1] - vPos[1][1]) * ((i&1) ? f : 1.0f); + float angle = (M_PI * i) / n; + float x = vPos[1][0] + (vPos[2][0] - vPos[1][0]) * cos(angle) * ((i&1) ? f : 1.0f); + float y = vPos[1][1] + (vPos[2][1] - vPos[1][1]) * sin(angle) * ((i&1) ? f : 1.0f); for(j = 0; j < 3; ++j) { float z = vPos[j][2]; @@ -1427,6 +1427,63 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: } } } + else if (eType == eXactCone) + { + int n = 6; // n = number of segments + setDims(2 * n + 1, 3); + + // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents); + // vPos[1] = aabb.origin; + // vPos[2] = vector3_added(aabb.origin, aabb.extents); + + int i, j; + float f = 1 / cos(M_PI / n); + for(i = 0; i < 2*n+1; ++i) + { + float angle = (M_PI * i) / n; + for(j = 0; j < 3; ++j) + { + float x = vPos[1][0] + ((2-j)/2.0f) * (vPos[2][0] - vPos[1][0]) * cos(angle) * ((i&1) ? f : 1.0f); + float y = vPos[1][1] + ((2-j)/2.0f) * (vPos[2][1] - vPos[1][1]) * sin(angle) * ((i&1) ? f : 1.0f); + float z = vPos[j][2]; + PatchControl *v; + v = &m_ctrl.data()[j*(2*n+1)+i]; + v->m_vertex[0] = x; + v->m_vertex[1] = y; + v->m_vertex[2] = z; + } + } + } + else if (eType == eXactSphere) + { + int n = 6; // n = number of segments + int m = 3; // m = number of segments + setDims(2 * n + 1, 2 * m + 1); + + // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents); + // vPos[1] = aabb.origin; + // vPos[2] = vector3_added(aabb.origin, aabb.extents); + + int i, j; + float f = 1 / cos(M_PI / n); + float g = 1 / cos(M_PI / (2*m)); + for(i = 0; i < 2*n+1; ++i) + { + float angle = (M_PI * i) / n; + for(j = 0; j < 2*m+1; ++j) + { + float angle2 = (M_PI * j) / (2*m); + float x = vPos[1][0] + (vPos[2][0] - vPos[1][0]) * sin(angle2) * ((j&1) ? g : 1.0f) * cos(angle) * ((i&1) ? f : 1.0f); + float y = vPos[1][1] + (vPos[2][1] - vPos[1][1]) * sin(angle2) * ((j&1) ? g : 1.0f) * sin(angle) * ((i&1) ? f : 1.0f); + float z = vPos[1][2] + (vPos[2][2] - vPos[1][2]) * -cos(angle2) * ((j&1) ? g : 1.0f); + PatchControl *v; + v = &m_ctrl.data()[j*(2*n+1)+i]; + v->m_vertex[0] = x; + v->m_vertex[1] = y; + v->m_vertex[2] = z; + } + } + } else if (eType == eBevel) { unsigned char *pIndex; diff --git a/radiant/patch.h b/radiant/patch.h index 61ecba9b..403c43bc 100644 --- a/radiant/patch.h +++ b/radiant/patch.h @@ -103,6 +103,8 @@ enum EPatchPrefab eCone, eSphere, eXactCylinder, + eXactSphere, + eXactCone, }; enum EMatrixMajor diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 46818cf0..744f29af 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -439,6 +439,20 @@ void Patch_XactCylinder() Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eXactCylinder, GlobalXYWnd_getCurrentViewType()); } +void Patch_XactSphere() +{ + UndoableCommand undo("patchCreateXactSphere"); + + Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eXactSphere, GlobalXYWnd_getCurrentViewType()); +} + +void Patch_XactCone() +{ + UndoableCommand undo("patchCreateXactCone"); + + Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eXactCone, GlobalXYWnd_getCurrentViewType()); +} + void Patch_Cylinder() { UndoableCommand undo("patchCreateCylinder"); @@ -750,10 +764,12 @@ void Patch_registerCommands() GlobalCommands_insert("DecPatchRow", FreeCaller(), Accelerator(GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK)); GlobalCommands_insert("NaturalizePatch", FreeCaller(), Accelerator('N', (GdkModifierType)GDK_CONTROL_MASK)); GlobalCommands_insert("PatchCylinder", FreeCaller()); - GlobalCommands_insert("PatchXactCylinder", FreeCaller()); GlobalCommands_insert("PatchDenseCylinder", FreeCaller()); GlobalCommands_insert("PatchVeryDenseCylinder", FreeCaller()); GlobalCommands_insert("PatchSquareCylinder", FreeCaller()); + GlobalCommands_insert("PatchXactCylinder", FreeCaller()); + GlobalCommands_insert("PatchXactSphere", FreeCaller()); + GlobalCommands_insert("PatchXactCone", FreeCaller()); GlobalCommands_insert("PatchEndCap", FreeCaller()); GlobalCommands_insert("PatchBevel", FreeCaller()); GlobalCommands_insert("PatchSquareBevel", FreeCaller()); @@ -796,7 +812,7 @@ void Patch_constructMenu(GtkMenu* menu) create_menu_item_with_mnemonic(menu_in_menu, "Dense Cylinder", "PatchDenseCylinder"); create_menu_item_with_mnemonic(menu_in_menu, "Very Dense Cylinder", "PatchVeryDenseCylinder"); create_menu_item_with_mnemonic(menu_in_menu, "Square Cylinder", "PatchSquareCylinder"); - create_menu_item_with_mnemonic(menu_in_menu, "Exact Cylinder", "PatchXactCylinder"); + create_menu_item_with_mnemonic(menu_in_menu, "Exact Cylinder...", "PatchXactCylinder"); } menu_separator (menu); create_menu_item_with_mnemonic(menu, "End cap", "PatchEndCap"); @@ -810,7 +826,10 @@ void Patch_constructMenu(GtkMenu* menu) } menu_separator (menu); create_menu_item_with_mnemonic(menu, "Cone", "PatchCone"); + create_menu_item_with_mnemonic(menu, "Exact Cone...", "PatchXactCone"); + menu_separator (menu); create_menu_item_with_mnemonic(menu, "Sphere", "PatchSphere"); + create_menu_item_with_mnemonic(menu, "Exact Sphere...", "PatchXactSphere"); menu_separator (menu); create_menu_item_with_mnemonic(menu, "Simple Patch Mesh...", "SimplePatchMesh"); menu_separator (menu); From 9032995bd3df12fc6e695446927aaad929c40747 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 7 Oct 2011 12:35:50 +0200 Subject: [PATCH 8/9] refactor DoNewPatchDlg --- radiant/patchmanip.cpp | 74 ++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 744f29af..144c1799 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -517,13 +517,13 @@ void Patch_Cone() Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eCone, GlobalXYWnd_getCurrentViewType()); } -void DoNewPatchDlg(); +void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int maxrows, int maxcols); void Patch_Plane() { UndoableCommand undo("patchCreatePlane"); - DoNewPatchDlg(); + DoNewPatchDlg(ePlane, 3, 3, 0, 0); } void Patch_InsertInsertColumn() @@ -894,7 +894,7 @@ void Patch_constructMenu(GtkMenu* menu) #include "gtkutil/dialog.h" #include "gtkutil/widget.h" -void DoNewPatchDlg() +void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int maxrows, int maxcols) { ModalDialog dialog; GtkComboBox* width; @@ -930,21 +930,22 @@ void DoNewPatchDlg() { GtkComboBox* combo = GTK_COMBO_BOX(gtk_combo_box_new_text()); - gtk_combo_box_append_text(combo, "3"); - gtk_combo_box_append_text(combo, "5"); - gtk_combo_box_append_text(combo, "7"); - gtk_combo_box_append_text(combo, "9"); - gtk_combo_box_append_text(combo, "11"); - gtk_combo_box_append_text(combo, "13"); - gtk_combo_box_append_text(combo, "15"); - gtk_combo_box_append_text(combo, "17"); - gtk_combo_box_append_text(combo, "19"); - gtk_combo_box_append_text(combo, "21"); - gtk_combo_box_append_text(combo, "23"); - gtk_combo_box_append_text(combo, "25"); - gtk_combo_box_append_text(combo, "27"); - gtk_combo_box_append_text(combo, "29"); - gtk_combo_box_append_text(combo, "31"); // MAX_PATCH_SIZE is 32, so we should be able to do 31... +#define D_ITEM(x) if(x >= mincols && (!maxcols || x <= maxcols)) gtk_combo_box_append_text(combo, #x) + D_ITEM(3); + D_ITEM(5); + D_ITEM(7); + D_ITEM(9); + D_ITEM(11); + D_ITEM(13); + D_ITEM(15); + D_ITEM(17); + D_ITEM(19); + D_ITEM(21); + D_ITEM(23); + D_ITEM(25); + D_ITEM(27); + D_ITEM(29); + D_ITEM(31); // MAX_PATCH_SIZE is 32, so we should be able to do 31... gtk_widget_show(GTK_WIDGET(combo)); gtk_table_attach(table, GTK_WIDGET(combo), 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), @@ -954,21 +955,22 @@ void DoNewPatchDlg() } { GtkComboBox* combo = GTK_COMBO_BOX(gtk_combo_box_new_text()); - gtk_combo_box_append_text(combo, "3"); - gtk_combo_box_append_text(combo, "5"); - gtk_combo_box_append_text(combo, "7"); - gtk_combo_box_append_text(combo, "9"); - gtk_combo_box_append_text(combo, "11"); - gtk_combo_box_append_text(combo, "13"); - gtk_combo_box_append_text(combo, "15"); - gtk_combo_box_append_text(combo, "17"); - gtk_combo_box_append_text(combo, "19"); - gtk_combo_box_append_text(combo, "21"); - gtk_combo_box_append_text(combo, "23"); - gtk_combo_box_append_text(combo, "25"); - gtk_combo_box_append_text(combo, "27"); - gtk_combo_box_append_text(combo, "29"); - gtk_combo_box_append_text(combo, "31"); // MAX_PATCH_SIZE is 32, so we should be able to do 31... +#define D_ITEM(x) if(x >= minrows && (!maxrows || x <= maxrows)) gtk_combo_box_append_text(combo, #x) + D_ITEM(3); + D_ITEM(5); + D_ITEM(7); + D_ITEM(9); + D_ITEM(11); + D_ITEM(13); + D_ITEM(15); + D_ITEM(17); + D_ITEM(19); + D_ITEM(21); + D_ITEM(23); + D_ITEM(25); + D_ITEM(27); + D_ITEM(29); + D_ITEM(31); // MAX_PATCH_SIZE is 32, so we should be able to do 31... gtk_widget_show(GTK_WIDGET(combo)); gtk_table_attach(table, GTK_WIDGET(combo), 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), @@ -1002,10 +1004,10 @@ void DoNewPatchDlg() if(modal_dialog_show(window, dialog) == eIDOK) { - int w = gtk_combo_box_get_active(width) * 2 + 3; - int h = gtk_combo_box_get_active(height) * 2 + 3; + int w = gtk_combo_box_get_active(width) * 2 + mincols; + int h = gtk_combo_box_get_active(height) * 2 + minrows; - Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), ePlane, GlobalXYWnd_getCurrentViewType(), w, h); + Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), prefab, GlobalXYWnd_getCurrentViewType(), w, h); } gtk_widget_destroy(GTK_WIDGET(window)); From 2f60e8694a88d5d470391316052399428209aeeb Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 7 Oct 2011 14:06:03 +0200 Subject: [PATCH 9/9] make dialogs for all "Xact" spheres/cones/cylinders --- radiant/patch.cpp | 42 +++++++++++++++++++++--------------------- radiant/patchmanip.cpp | 20 +++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 9ecb6499..5b2622bb 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -1402,8 +1402,8 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: } else if (eType == eXactCylinder) { - int n = 6; // n = number of segments - setDims(2 * n + 1, 3); + int n = (width - 1) / 2; // n = number of segments + setDims(width, height); // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents); // vPos[1] = aabb.origin; @@ -1411,16 +1411,16 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: int i, j; float f = 1 / cos(M_PI / n); - for(i = 0; i < 2*n+1; ++i) + for(i = 0; i < width; ++i) { - float angle = (M_PI * i) / n; + float angle = (M_PI * i) / n; // 0 to 2pi float x = vPos[1][0] + (vPos[2][0] - vPos[1][0]) * cos(angle) * ((i&1) ? f : 1.0f); float y = vPos[1][1] + (vPos[2][1] - vPos[1][1]) * sin(angle) * ((i&1) ? f : 1.0f); - for(j = 0; j < 3; ++j) + for(j = 0; j < height; ++j) { - float z = vPos[j][2]; + float z = vPos[0][2] + (vPos[2][2] - vPos[0][2]) * (j / (float)(height - 1)); PatchControl *v; - v = &m_ctrl.data()[j*(2*n+1)+i]; + v = &m_ctrl.data()[j*width+i]; v->m_vertex[0] = x; v->m_vertex[1] = y; v->m_vertex[2] = z; @@ -1429,8 +1429,8 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: } else if (eType == eXactCone) { - int n = 6; // n = number of segments - setDims(2 * n + 1, 3); + int n = (width - 1) / 2; // n = number of segments + setDims(width, height); // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents); // vPos[1] = aabb.origin; @@ -1438,16 +1438,16 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: int i, j; float f = 1 / cos(M_PI / n); - for(i = 0; i < 2*n+1; ++i) + for(i = 0; i < width; ++i) { float angle = (M_PI * i) / n; - for(j = 0; j < 3; ++j) + for(j = 0; j < height; ++j) { - float x = vPos[1][0] + ((2-j)/2.0f) * (vPos[2][0] - vPos[1][0]) * cos(angle) * ((i&1) ? f : 1.0f); - float y = vPos[1][1] + ((2-j)/2.0f) * (vPos[2][1] - vPos[1][1]) * sin(angle) * ((i&1) ? f : 1.0f); - float z = vPos[j][2]; + float x = vPos[1][0] + (1.0f - (j / (float)(height - 1))) * (vPos[2][0] - vPos[1][0]) * cos(angle) * ((i&1) ? f : 1.0f); + float y = vPos[1][1] + (1.0f - (j / (float)(height - 1))) * (vPos[2][1] - vPos[1][1]) * sin(angle) * ((i&1) ? f : 1.0f); + float z = vPos[0][2] + (vPos[2][2] - vPos[0][2]) * (j / (float)(height - 1)); PatchControl *v; - v = &m_ctrl.data()[j*(2*n+1)+i]; + v = &m_ctrl.data()[j*width+i]; v->m_vertex[0] = x; v->m_vertex[1] = y; v->m_vertex[2] = z; @@ -1456,9 +1456,9 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: } else if (eType == eXactSphere) { - int n = 6; // n = number of segments - int m = 3; // m = number of segments - setDims(2 * n + 1, 2 * m + 1); + int n = (width - 1) / 2; // n = number of segments (yaw) + int m = (height - 1) / 2; // m = number of segments (pitch) + setDims(width, height); // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents); // vPos[1] = aabb.origin; @@ -1467,17 +1467,17 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std: int i, j; float f = 1 / cos(M_PI / n); float g = 1 / cos(M_PI / (2*m)); - for(i = 0; i < 2*n+1; ++i) + for(i = 0; i < width; ++i) { float angle = (M_PI * i) / n; - for(j = 0; j < 2*m+1; ++j) + for(j = 0; j < height; ++j) { float angle2 = (M_PI * j) / (2*m); float x = vPos[1][0] + (vPos[2][0] - vPos[1][0]) * sin(angle2) * ((j&1) ? g : 1.0f) * cos(angle) * ((i&1) ? f : 1.0f); float y = vPos[1][1] + (vPos[2][1] - vPos[1][1]) * sin(angle2) * ((j&1) ? g : 1.0f) * sin(angle) * ((i&1) ? f : 1.0f); float z = vPos[1][2] + (vPos[2][2] - vPos[1][2]) * -cos(angle2) * ((j&1) ? g : 1.0f); PatchControl *v; - v = &m_ctrl.data()[j*(2*n+1)+i]; + v = &m_ctrl.data()[j*width+i]; v->m_vertex[0] = x; v->m_vertex[1] = y; v->m_vertex[2] = z; diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 144c1799..6829fee7 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -432,25 +432,27 @@ AABB PatchCreator_getBounds() return AABB(Vector3(0, 0, 0), Vector3(64, 64, 64)); } +void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols); + void Patch_XactCylinder() { UndoableCommand undo("patchCreateXactCylinder"); - Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eXactCylinder, GlobalXYWnd_getCurrentViewType()); + DoNewPatchDlg(eXactCylinder, 3, 7, 3, 13, 0, 0); } void Patch_XactSphere() { UndoableCommand undo("patchCreateXactSphere"); - Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eXactSphere, GlobalXYWnd_getCurrentViewType()); + DoNewPatchDlg(eXactSphere, 5, 7, 7, 13, 0, 0); } void Patch_XactCone() { UndoableCommand undo("patchCreateXactCone"); - Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eXactCone, GlobalXYWnd_getCurrentViewType()); + DoNewPatchDlg(eXactCone, 3, 7, 3, 13, 0, 0); } void Patch_Cylinder() @@ -517,13 +519,11 @@ void Patch_Cone() Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eCone, GlobalXYWnd_getCurrentViewType()); } -void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int maxrows, int maxcols); - void Patch_Plane() { UndoableCommand undo("patchCreatePlane"); - DoNewPatchDlg(ePlane, 3, 3, 0, 0); + DoNewPatchDlg(ePlane, 3, 3, 3, 3, 0, 0); } void Patch_InsertInsertColumn() @@ -894,7 +894,7 @@ void Patch_constructMenu(GtkMenu* menu) #include "gtkutil/dialog.h" #include "gtkutil/widget.h" -void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int maxrows, int maxcols) +void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols) { ModalDialog dialog; GtkComboBox* width; @@ -946,6 +946,7 @@ void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int maxrows, i D_ITEM(27); D_ITEM(29); D_ITEM(31); // MAX_PATCH_SIZE is 32, so we should be able to do 31... +#undef D_ITEM gtk_widget_show(GTK_WIDGET(combo)); gtk_table_attach(table, GTK_WIDGET(combo), 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), @@ -971,6 +972,7 @@ void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int maxrows, i D_ITEM(27); D_ITEM(29); D_ITEM(31); // MAX_PATCH_SIZE is 32, so we should be able to do 31... +#undef D_ITEM gtk_widget_show(GTK_WIDGET(combo)); gtk_table_attach(table, GTK_WIDGET(combo), 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), @@ -999,8 +1001,8 @@ void DoNewPatchDlg(EPatchPrefab prefab, int minrows, int mincols, int maxrows, i } // Initialize dialog - gtk_combo_box_set_active(width, 0); - gtk_combo_box_set_active(height, 0); + gtk_combo_box_set_active(width, (defcols - mincols) / 2); + gtk_combo_box_set_active(height, (defrows - minrows) / 2); if(modal_dialog_show(window, dialog) == eIDOK) {