From 8ca384165b0bceb14d3743d4e255669077eab7ca Mon Sep 17 00:00:00 2001 From: Garux Date: Wed, 2 Aug 2017 09:40:29 +0300 Subject: [PATCH] Radiant: misc... * fix name case sensitivity in shaders (non plain textures) loading during map/model loading * all patch prefabs are created aligned to active projection --- plugins/shaders/shaders.cpp | 2 +- radiant/patch.cpp | 84 +++++++++++++++++++++---------------- radiant/selection.cpp | 14 ++++++- 3 files changed, 62 insertions(+), 38 deletions(-) diff --git a/plugins/shaders/shaders.cpp b/plugins/shaders/shaders.cpp index f1c140e5..cb7292ff 100644 --- a/plugins/shaders/shaders.cpp +++ b/plugins/shaders/shaders.cpp @@ -700,7 +700,7 @@ ShaderArguments args; const char* filename; }; -typedef std::map ShaderDefinitionMap; +typedef std::map ShaderDefinitionMap; ShaderDefinitionMap g_shaderDefinitions; diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 066e66ca..8638df23 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -1210,6 +1210,18 @@ void Patch::constructPlane( const AABB& aabb, int axis, std::size_t width, std:: void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std::size_t width, std::size_t height ){ Vector3 vPos[3]; + int x, y, z; + switch ( axis ) + { + case 2: x = 0; y = 1; z = 2; break; + //case 1: x = 0; y = 2; z = 1; break; + case 1: x = 2; y = 0; z = 1; break; + case 0: x = 1; y = 2; z = 0; break; + default: + ERROR_MESSAGE( "invalid view-type" ); + return; + } + if ( eType != ePlane ) { vPos[0] = vector3_subtracted( aabb.origin, aabb.extents ); vPos[1] = aabb.origin; @@ -1270,9 +1282,9 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std PatchControl* pCtrl = pStart; for ( std::size_t w = 0; w < 8; w++, pCtrl++ ) { - pCtrl->m_vertex[0] = vPos[pIndex[0]][0]; - pCtrl->m_vertex[1] = vPos[pIndex[1]][1]; - pCtrl->m_vertex[2] = vPos[h][2]; + pCtrl->m_vertex[x] = vPos[pIndex[0]][x]; + pCtrl->m_vertex[y] = vPos[pIndex[1]][y]; + pCtrl->m_vertex[z] = vPos[h][z]; pIndex += 2; } } @@ -1311,9 +1323,9 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std PatchControl* pCtrl = m_ctrl.data() + 9 * 2; for ( std::size_t w = 0; w < 9; w++, pCtrl++ ) { - pCtrl->m_vertex[0] = vPos[1][0]; - pCtrl->m_vertex[1] = vPos[1][1]; - pCtrl->m_vertex[2] = vPos[2][2]; + pCtrl->m_vertex[x] = vPos[1][x]; + pCtrl->m_vertex[y] = vPos[1][y]; + pCtrl->m_vertex[z] = vPos[2][z]; } } break; @@ -1329,18 +1341,18 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std PatchControl* pCtrl = m_ctrl.data(); for ( std::size_t w = 0; w < 9; w++, pCtrl++ ) { - pCtrl->m_vertex[0] = vPos[1][0]; - pCtrl->m_vertex[1] = vPos[1][1]; - pCtrl->m_vertex[2] = vPos[0][2]; + pCtrl->m_vertex[x] = vPos[1][x]; + pCtrl->m_vertex[y] = vPos[1][y]; + pCtrl->m_vertex[z] = vPos[0][z]; } } { PatchControl* pCtrl = m_ctrl.data() + ( 9 * 4 ); for ( std::size_t w = 0; w < 9; w++, pCtrl++ ) { - pCtrl->m_vertex[0] = vPos[1][0]; - pCtrl->m_vertex[1] = vPos[1][1]; - pCtrl->m_vertex[2] = vPos[2][2]; + pCtrl->m_vertex[x] = vPos[1][x]; + pCtrl->m_vertex[y] = vPos[1][y]; + pCtrl->m_vertex[z] = vPos[2][z]; } } break; @@ -1362,16 +1374,16 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std for ( i = 0; i < width; ++i ) { 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 ); + float x_ = vPos[1][x] + ( vPos[2][x] - vPos[1][x] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); + float y_ = vPos[1][y] + ( vPos[2][y] - vPos[1][y] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); for ( j = 0; j < height; ++j ) { - float z = vPos[0][2] + ( vPos[2][2] - vPos[0][2] ) * ( j / (float)( height - 1 ) ); + float z_ = vPos[0][z] + ( vPos[2][z] - vPos[0][z] ) * ( j / (float)( height - 1 ) ); PatchControl *v; v = &m_ctrl.data()[j * width + i]; - v->m_vertex[0] = x; - v->m_vertex[1] = y; - v->m_vertex[2] = z; + v->m_vertex[x] = x_; + v->m_vertex[y] = y_; + v->m_vertex[z] = z_; } } } @@ -1390,14 +1402,14 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std float angle = ( M_PI * i ) / n; for ( j = 0; j < height; ++j ) { - 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 ) ); + float x_ = vPos[1][x] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][x] - vPos[1][x] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); + float y_ = vPos[1][y] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][y] - vPos[1][y] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); + float z_ = vPos[0][z] + ( vPos[2][z] - vPos[0][z] ) * ( j / (float)( height - 1 ) ); PatchControl *v; v = &m_ctrl.data()[j * width + i]; - v->m_vertex[0] = x; - v->m_vertex[1] = y; - v->m_vertex[2] = z; + v->m_vertex[x] = x_; + v->m_vertex[y] = y_; + v->m_vertex[z] = z_; } } } @@ -1419,14 +1431,14 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std 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 ); + float x_ = vPos[1][x] + ( vPos[2][x] - vPos[1][x] ) * sin( angle2 ) * ( ( j & 1 ) ? g : 1.0f ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); + float y_ = vPos[1][y] + ( vPos[2][y] - vPos[1][y] ) * sin( angle2 ) * ( ( j & 1 ) ? g : 1.0f ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); + float z_ = vPos[1][z] + ( vPos[2][z] - vPos[1][z] ) * -cos( angle2 ) * ( ( j & 1 ) ? g : 1.0f ); PatchControl *v; v = &m_ctrl.data()[j * width + i]; - v->m_vertex[0] = x; - v->m_vertex[1] = y; - v->m_vertex[2] = z; + v->m_vertex[x] = x_; + v->m_vertex[y] = y_; + v->m_vertex[z] = z_; } } } @@ -1447,9 +1459,9 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std pIndex = pBevIndex; for ( std::size_t w = 0; w < 3; w++, pIndex += 2, pCtrl++ ) { - pCtrl->m_vertex[0] = vPos[pIndex[0]][0]; - pCtrl->m_vertex[1] = vPos[pIndex[1]][1]; - pCtrl->m_vertex[2] = vPos[h][2]; + pCtrl->m_vertex[x] = vPos[pIndex[0]][x]; + pCtrl->m_vertex[y] = vPos[pIndex[1]][y]; + pCtrl->m_vertex[z] = vPos[h][z]; } } } @@ -1472,9 +1484,9 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std pIndex = pEndIndex; for ( std::size_t w = 0; w < 5; w++, pIndex += 2, pCtrl++ ) { - pCtrl->m_vertex[0] = vPos[pIndex[0]][0]; - pCtrl->m_vertex[1] = vPos[pIndex[1]][1]; - pCtrl->m_vertex[2] = vPos[h][2]; + pCtrl->m_vertex[x] = vPos[pIndex[0]][x]; + pCtrl->m_vertex[y] = vPos[pIndex[1]][y]; + pCtrl->m_vertex[z] = vPos[h][z]; } } } diff --git a/radiant/selection.cpp b/radiant/selection.cpp index daa7ee78..2a58b5f1 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -3073,7 +3073,7 @@ void deselectComponentsOrAll( bool components ){ deselectAll(); } } - +#define SELECT_MATCHING void SelectPoint( const View& view, const float device_point[2], const float device_epsilon[2], RadiantSelectionSystem::EModifier modifier, bool face ){ //globalOutputStream() << device_point[0] << " " << device_point[1] << "\n"; ASSERT_MESSAGE( fabs( device_point[0] ) <= 1.0f && fabs( device_point[1] ) <= 1.0f, "point-selection error" ); @@ -3120,6 +3120,7 @@ void SelectPoint( const View& view, const float device_point[2], const float dev if( !( *best ).second->isSelected() ){ ( *best ).second->setSelected( true ); } +#ifdef SELECT_MATCHING SelectionPool::iterator i = best; ++i; while ( i != selector_point_ents.end() ) @@ -3134,6 +3135,7 @@ void SelectPoint( const View& view, const float device_point[2], const float dev } ++i; } +#endif // SELECT_MATCHING } break; case RadiantSelectionSystem::eDeselect: @@ -3142,6 +3144,7 @@ void SelectPoint( const View& view, const float device_point[2], const float dev if( ( *best ).second->isSelected() ){ ( *best ).second->setSelected( false ); } +#ifdef SELECT_MATCHING SelectionPool::iterator i = best; ++i; while ( i != selector_point_ents.end() ) @@ -3156,6 +3159,7 @@ void SelectPoint( const View& view, const float device_point[2], const float dev } ++i; } +#endif // SELECT_MATCHING } break; default: @@ -3226,6 +3230,7 @@ void SelectPoint( const View& view, const float device_point[2], const float dev if( !( *best ).second->isSelected() ){ ( *best ).second->setSelected( true ); } +#ifdef SELECT_MATCHING SelectionPool::iterator i = best; ++i; while ( i != selector.end() ) @@ -3240,6 +3245,7 @@ void SelectPoint( const View& view, const float device_point[2], const float dev } ++i; } +#endif // SELECT_MATCHING } break; case RadiantSelectionSystem::eDeselect: @@ -3248,6 +3254,7 @@ void SelectPoint( const View& view, const float device_point[2], const float dev if( ( *best ).second->isSelected() ){ ( *best ).second->setSelected( false ); } +#ifdef SELECT_MATCHING SelectionPool::iterator i = best; ++i; while ( i != selector.end() ) @@ -3262,6 +3269,7 @@ void SelectPoint( const View& view, const float device_point[2], const float dev } ++i; } +#endif // SELECT_MATCHING } break; default: @@ -3297,6 +3305,7 @@ bool SelectPoint_InitPaint( const View& view, const float device_point[2], const SelectableSortedSet::iterator best = selector_point_ents.begin(); const bool wasSelected = ( *best ).second->isSelected(); ( *best ).second->setSelected( !wasSelected ); +#ifdef SELECT_MATCHING SelectableSortedSet::iterator i = best; ++i; while ( i != selector_point_ents.end() ) @@ -3309,6 +3318,7 @@ bool SelectPoint_InitPaint( const View& view, const float device_point[2], const } ++i; } +#endif // SELECT_MATCHING return !wasSelected; } else{//do primitives, if ents failed @@ -3322,6 +3332,7 @@ bool SelectPoint_InitPaint( const View& view, const float device_point[2], const SelectableSortedSet::iterator best = selector.begin(); const bool wasSelected = ( *best ).second->isSelected(); ( *best ).second->setSelected( !wasSelected ); +#ifdef SELECT_MATCHING SelectableSortedSet::iterator i = best; ++i; while ( i != selector.end() ) @@ -3334,6 +3345,7 @@ bool SelectPoint_InitPaint( const View& view, const float device_point[2], const } ++i; } +#endif // SELECT_MATCHING return !wasSelected; } else{