mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 00:09:18 +02:00
reformat: remove redundant parentheses
This commit is contained in:
169
scene/scene.cpp
169
scene/scene.cpp
@@ -34,9 +34,9 @@ void
|
||||
basic_cell::on_click( TAnimModel const *Instance ) {
|
||||
|
||||
for( auto *launcher : m_eventlaunchers ) {
|
||||
if( ( launcher->name() == Instance->name() )
|
||||
&& ( glm::length2( launcher->location() - Instance->location() ) < launcher->dRadius )
|
||||
&& ( true == launcher->check_conditions() ) ) {
|
||||
if( launcher->name() == Instance->name()
|
||||
&& glm::length2(launcher->location() - Instance->location()) < launcher->dRadius
|
||||
&& true == launcher->check_conditions() ) {
|
||||
launch_event( launcher, true );
|
||||
}
|
||||
}
|
||||
@@ -52,8 +52,8 @@ basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex
|
||||
auto const position = Vehicle->GetPosition(); // współrzędne środka pojazdu
|
||||
|
||||
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
|
||||
auto const pantographposition = position + ( vLeft * pantograph->vPos.z ) + ( vUp * pantograph->vPos.y ) + ( vFront * pantograph->vPos.x );
|
||||
|
||||
auto const pantographposition = position + vLeft * pantograph->vPos.z + vUp * pantograph->vPos.y + vFront * pantograph->vPos.x;
|
||||
|
||||
for( auto *traction : m_directories.traction ) {
|
||||
|
||||
// współczynniki równania parametrycznego
|
||||
@@ -64,8 +64,8 @@ basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex
|
||||
paramfrontdot :
|
||||
0.001 ); // div0 trap
|
||||
|
||||
if( ( fRaParam < -0.001 )
|
||||
|| ( fRaParam > 1.001 ) ) { continue; }
|
||||
if( fRaParam < -0.001
|
||||
|| fRaParam > 1.001 ) { continue; }
|
||||
// jeśli tylko jest w przedziale, wyznaczyć odległość wzdłuż wektorów vUp i vLeft
|
||||
// punkt styku płaszczyzny z drutem (dla generatora łuku el.)
|
||||
auto const vStyk = traction->pPoint1 + fRaParam * traction->vParametric;
|
||||
@@ -76,8 +76,8 @@ basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex
|
||||
// jeśli ponad pantografem (bo może łapać druty spod wiaduktu)
|
||||
auto const fHorizontal = std::abs( glm::dot( vGdzie, vLeft ) ) - pantograph->fWidth;
|
||||
|
||||
if( ( Global.bEnableTraction )
|
||||
&& ( fVertical < pantograph->PantWys - 0.15 ) ) {
|
||||
if (Global.bEnableTraction
|
||||
&& fVertical < pantograph->PantWys - 0.15 ) {
|
||||
// jeśli drut jest niżej niż 15cm pod ślizgiem przełączamy w tryb połamania, o ile jedzie;
|
||||
// (bEnableTraction) aby dało się jeździć na koślawych sceneriach
|
||||
// i do tego jeszcze wejdzie pod ślizg
|
||||
@@ -185,8 +185,8 @@ basic_cell::RaTrackAnimAdd( TTrack *Track ) {
|
||||
void
|
||||
basic_cell::RaAnimate( unsigned int const Framestamp ) {
|
||||
|
||||
if( ( tTrackAnim == nullptr )
|
||||
|| ( Framestamp == m_framestamp ) ) {
|
||||
if( tTrackAnim == nullptr
|
||||
|| Framestamp == m_framestamp ) {
|
||||
// nie ma nic do animowania
|
||||
return;
|
||||
}
|
||||
@@ -244,11 +244,7 @@ basic_cell::deserialize( std::istream &Input ) {
|
||||
m_lines.emplace_back( lines_node().deserialize( Input ) );
|
||||
}
|
||||
// cell activation flag
|
||||
m_active = (
|
||||
( true == m_active )
|
||||
|| ( false == m_shapesopaque.empty() )
|
||||
|| ( false == m_shapestranslucent.empty() )
|
||||
|| ( false == m_lines.empty() ) );
|
||||
m_active = true == m_active || false == m_shapesopaque.empty() || false == m_shapestranslucent.empty() || false == m_lines.empty();
|
||||
}
|
||||
|
||||
// sends content of the class in legacy (text) format to provided stream
|
||||
@@ -274,18 +270,15 @@ basic_cell::insert( shape_node Shape ) {
|
||||
glm::length( m_area.center - Shape.data().area.center ) + Shape.radius() );
|
||||
|
||||
auto const &shapedata { Shape.data() };
|
||||
auto &shapes = (
|
||||
shapedata.translucent ?
|
||||
m_shapestranslucent :
|
||||
m_shapesopaque );
|
||||
auto &shapes = shapedata.translucent ? m_shapestranslucent : m_shapesopaque;
|
||||
for( auto &targetshape : shapes ) {
|
||||
// try to merge shapes with matching view ranges...
|
||||
auto const &targetshapedata { targetshape.data() };
|
||||
if( ( shapedata.rangesquared_min == targetshapedata.rangesquared_min )
|
||||
&& ( shapedata.rangesquared_max == targetshapedata.rangesquared_max )
|
||||
if( shapedata.rangesquared_min == targetshapedata.rangesquared_min
|
||||
&& shapedata.rangesquared_max == targetshapedata.rangesquared_max
|
||||
// ...and located close to each other (within arbitrary limit of 25m)
|
||||
// length2 is better than length for comparing because it does not require sqrt function
|
||||
&& ( glm::length2( shapedata.area.center - targetshapedata.area.center ) < sq(25.0) ) ) {
|
||||
&& glm::length2(shapedata.area.center - targetshapedata.area.center) < sq(25.0) ) {
|
||||
|
||||
if( true == targetshape.merge( Shape ) ) {
|
||||
// if the shape was merged there's nothing left to do
|
||||
@@ -308,11 +301,11 @@ basic_cell::insert( lines_node Lines ) {
|
||||
for( auto &targetlines : m_lines ) {
|
||||
// try to merge shapes with matching view ranges...
|
||||
auto const &targetlinesdata { targetlines.data() };
|
||||
if( ( linesdata.rangesquared_min == targetlinesdata.rangesquared_min )
|
||||
&& ( linesdata.rangesquared_max == targetlinesdata.rangesquared_max )
|
||||
if( linesdata.rangesquared_min == targetlinesdata.rangesquared_min
|
||||
&& linesdata.rangesquared_max == targetlinesdata.rangesquared_max
|
||||
// ...and located close to each other (within arbitrary limit of 10m)
|
||||
// length2 is better than length for comparing because it does not require sqrt function
|
||||
&& ( glm::length2( linesdata.area.center - targetlinesdata.area.center ) < sq(10.0) ) ) {
|
||||
&& glm::length2(linesdata.area.center - targetlinesdata.area.center) < sq(10.0) ) {
|
||||
|
||||
if( true == targetlines.merge( Lines ) ) {
|
||||
// if the shape was merged there's nothing left to do
|
||||
@@ -361,9 +354,7 @@ basic_cell::insert( TAnimModel *Instance ) {
|
||||
|
||||
auto const flags = Instance->Flags();
|
||||
auto alpha =
|
||||
( Instance->Material() != nullptr ?
|
||||
Instance->Material()->textures_alpha :
|
||||
0x30300030 );
|
||||
Instance->Material() != nullptr ? Instance->Material()->textures_alpha : 0x30300030;
|
||||
|
||||
// assign model to appropriate render phases
|
||||
if( alpha & flags & 0x2F2F002F ) {
|
||||
@@ -431,9 +422,7 @@ basic_cell::erase( TAnimModel *Instance ) {
|
||||
|
||||
auto const flags = Instance->Flags();
|
||||
auto alpha =
|
||||
( Instance->Material() != nullptr ?
|
||||
Instance->Material()->textures_alpha :
|
||||
0x30300030 );
|
||||
Instance->Material() != nullptr ? Instance->Material()->textures_alpha : 0x30300030;
|
||||
|
||||
if( alpha & flags & 0x2F2F002F ) {
|
||||
// instance has translucent pieces
|
||||
@@ -524,8 +513,8 @@ basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlyco
|
||||
|
||||
for( auto *path : m_paths ) {
|
||||
for( auto *vehicle : path->Dynamics ) {
|
||||
if( ( true == Onlycontrolled )
|
||||
&& ( vehicle->Mechanik == nullptr ) ) {
|
||||
if( true == Onlycontrolled
|
||||
&& vehicle->Mechanik == nullptr ) {
|
||||
continue;
|
||||
}
|
||||
if( false == Findbycoupler ) {
|
||||
@@ -538,8 +527,8 @@ basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlyco
|
||||
glm::length2( glm::dvec3{ vehicle->HeadPosition() } - Point ),
|
||||
glm::length2( glm::dvec3{ vehicle->RearPosition() } - Point ) );
|
||||
}
|
||||
if( ( distance > distancecutoff )
|
||||
|| ( distance > leastdistance ) ){
|
||||
if( distance > distancecutoff
|
||||
|| distance > leastdistance ){
|
||||
continue;
|
||||
}
|
||||
std::tie( vehiclenearest, leastdistance ) = std::tie( vehicle, distance );
|
||||
@@ -599,19 +588,16 @@ basic_cell::find( glm::dvec3 const &Point, TTraction const *Other, int const Cur
|
||||
|
||||
for( auto *traction : m_directories.traction ) {
|
||||
|
||||
if( ( traction == Other )
|
||||
|| ( traction->psSection != Other->psSection )
|
||||
|| ( traction == Other->hvNext[ 0 ] )
|
||||
|| ( traction == Other->hvNext[ 1 ] ) ) {
|
||||
if( traction == Other
|
||||
|| traction->psSection != Other->psSection
|
||||
|| traction == Other->hvNext[0]
|
||||
|| traction == Other->hvNext[1] ) {
|
||||
// ignore pieces from different sections, and ones connected to the other piece
|
||||
continue;
|
||||
}
|
||||
endpoint = (
|
||||
glm::dot( traction->vParametric, Other->vParametric ) >= 0.0 ?
|
||||
Currentdirection ^ 1 :
|
||||
Currentdirection );
|
||||
if( ( traction->psPower[ endpoint ] == nullptr )
|
||||
|| ( traction->fResistance[ endpoint ] < 0.0 ) ) {
|
||||
endpoint = glm::dot(traction->vParametric, Other->vParametric) >= 0.0 ? Currentdirection ^ 1 : Currentdirection;
|
||||
if( traction->psPower[endpoint] == nullptr
|
||||
|| traction->fResistance[endpoint] < 0.0 ) {
|
||||
continue;
|
||||
}
|
||||
distance = glm::length2( traction->location() - Point );
|
||||
@@ -728,7 +714,7 @@ basic_section::update_traction( TDynamicObject *Vehicle, int const Pantographind
|
||||
auto const position = Vehicle->GetPosition(); // współrzędne środka pojazdu
|
||||
|
||||
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
|
||||
auto const pantographposition = position + ( vLeft * pantograph->vPos.z ) + ( vUp * pantograph->vPos.y ) + ( vFront * pantograph->vPos.x );
|
||||
auto const pantographposition = position + vLeft * pantograph->vPos.z + vUp * pantograph->vPos.y + vFront * pantograph->vPos.x;
|
||||
|
||||
auto const radius { EU07_CELLSIZE * 0.5 }; // redius around point of interest
|
||||
|
||||
@@ -802,7 +788,7 @@ basic_section::serialize( std::ostream &Output ) const {
|
||||
// all done; calculate and record section size
|
||||
auto const sectionendpos { Output.tellp() };
|
||||
Output.seekp( sectionstartpos );
|
||||
sn_utils::ls_uint32( Output, static_cast<uint32_t>( ( sizeof( uint32_t ) + ( sectionendpos - sectionstartpos ) ) ) );
|
||||
sn_utils::ls_uint32( Output, static_cast<uint32_t>( sizeof(uint32_t) + (sectionendpos - sectionstartpos) ) );
|
||||
Output.seekp( sectionendpos );
|
||||
}
|
||||
|
||||
@@ -845,9 +831,9 @@ basic_section::insert( shape_node Shape ) {
|
||||
m_area.radius,
|
||||
static_cast<float>( glm::length( m_area.center - shapedata.area.center ) + Shape.radius() ) );
|
||||
|
||||
if( ( true == shapedata.translucent )
|
||||
|| ( shapedata.rangesquared_max <= 90000.0 )
|
||||
|| ( shapedata.rangesquared_min > 0.0 ) ) {
|
||||
if( true == shapedata.translucent
|
||||
|| shapedata.rangesquared_max <= 90000.0
|
||||
|| shapedata.rangesquared_min > 0.0 ) {
|
||||
// small, translucent or not always visible shapes are placed in the sub-cells
|
||||
cell( shapedata.area.center ).insert( Shape );
|
||||
}
|
||||
@@ -891,8 +877,8 @@ basic_section::find( glm::dvec3 const &Point, float const Radius, bool const Onl
|
||||
continue;
|
||||
}
|
||||
std::tie( vehiclefound, distancefound ) = cell.find( Point, Radius, Onlycontrolled, Findbycoupler );
|
||||
if( ( vehiclefound != nullptr )
|
||||
&& ( distancefound < distancenearest ) ) {
|
||||
if( vehiclefound != nullptr
|
||||
&& distancefound < distancenearest ) {
|
||||
|
||||
std::tie( vehiclenearest, distancenearest ) = std::tie( vehiclefound, distancefound );
|
||||
}
|
||||
@@ -937,8 +923,8 @@ basic_section::find( glm::dvec3 const &Point, TTraction const *Other, int const
|
||||
continue;
|
||||
}
|
||||
std::tie( tractionfound, endpointfound, distancefound ) = cell.find( Point, Other, Currentdirection );
|
||||
if( ( tractionfound != nullptr )
|
||||
&& ( distancefound < distancenearest ) ) {
|
||||
if( tractionfound != nullptr
|
||||
&& distancefound < distancenearest ) {
|
||||
|
||||
std::tie( tractionnearest, endpointnearest, distancenearest ) = std::tie( tractionfound, endpointfound, distancefound );
|
||||
}
|
||||
@@ -1032,8 +1018,8 @@ basic_section::cell( glm::dvec3 const &Location, const glm::ivec2 &offset ) {
|
||||
|
||||
return
|
||||
m_cells[
|
||||
std::clamp( row, 0, ( EU07_SECTIONSIZE / EU07_CELLSIZE ) - 1 ) * ( EU07_SECTIONSIZE / EU07_CELLSIZE )
|
||||
+ std::clamp( column, 0, ( EU07_SECTIONSIZE / EU07_CELLSIZE ) - 1 ) ] ;
|
||||
std::clamp( row, 0, EU07_SECTIONSIZE / EU07_CELLSIZE - 1 ) * ( EU07_SECTIONSIZE / EU07_CELLSIZE )
|
||||
+ std::clamp( column, 0, EU07_SECTIONSIZE / EU07_CELLSIZE - 1 ) ] ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1052,7 +1038,7 @@ basic_region::~basic_region() {
|
||||
void
|
||||
basic_region::on_click( TAnimModel const *Instance ) {
|
||||
|
||||
if( Instance->name().empty() || ( Instance->name() == "none" ) ) { return; }
|
||||
if( Instance->name().empty() || Instance->name() == "none" ) { return; }
|
||||
|
||||
auto const& location { Instance->location() };
|
||||
|
||||
@@ -1096,7 +1082,7 @@ basic_region::update_traction( TDynamicObject *Vehicle, int const Pantographinde
|
||||
auto const position = Vehicle->GetPosition(); // współrzędne środka pojazdu
|
||||
|
||||
auto p = Vehicle->pants[ Pantographindex ].fParamPants;
|
||||
auto const pant0 = position + ( vLeft * p->vPos.z ) + ( vUp * p->vPos.y ) + ( vFront * p->vPos.x );
|
||||
auto const pant0 = position + vLeft * p->vPos.z + vUp * p->vPos.y + vFront * p->vPos.x;
|
||||
p->PantTraction = std::numeric_limits<double>::max(); // taka za duża wartość
|
||||
|
||||
auto const §ionlist = sections( pant0, EU07_CELLSIZE * 0.5 );
|
||||
@@ -1127,8 +1113,7 @@ basic_region::is_scene( std::string const &Scenariofile ) const {
|
||||
uint32_t headermain{ sn_utils::ld_uint32( input ) };
|
||||
uint32_t headertype{ sn_utils::ld_uint32( input ) };
|
||||
|
||||
if( ( headermain != EU07_FILEHEADER
|
||||
|| ( headertype != EU07_FILEVERSION_REGION ) ) ) {
|
||||
if( headermain != EU07_FILEHEADER || headertype != EU07_FILEVERSION_REGION ) {
|
||||
// wrong file type
|
||||
return false;
|
||||
}
|
||||
@@ -1199,8 +1184,7 @@ basic_region::deserialize( std::string const &Scenariofile ) {
|
||||
uint32_t headermain { sn_utils::ld_uint32( input ) };
|
||||
uint32_t headertype { sn_utils::ld_uint32( input ) };
|
||||
|
||||
if( ( headermain != EU07_FILEHEADER
|
||||
|| ( headertype != EU07_FILEVERSION_REGION ) ) ) {
|
||||
if( headermain != EU07_FILEHEADER || headertype != EU07_FILEVERSION_REGION ) {
|
||||
// wrong file type
|
||||
WriteLog( "Bad file: \"" + filename + "\" is of either unrecognized type or version" );
|
||||
return false;
|
||||
@@ -1326,8 +1310,8 @@ basic_region::insert( shape_node Shape, scratch_data &Scratchpad, bool const Tra
|
||||
vertex.normal = glm::rotateY( vertex.normal, rotation.y );
|
||||
}
|
||||
}
|
||||
if( ( false == Scratchpad.location.offset.empty() )
|
||||
&& ( Scratchpad.location.offset.top() != glm::dvec3( 0, 0, 0 ) ) ) {
|
||||
if( false == Scratchpad.location.offset.empty()
|
||||
&& Scratchpad.location.offset.top() != glm::dvec3(0, 0, 0) ) {
|
||||
// ...and move
|
||||
auto const& offset = Scratchpad.location.offset.top();
|
||||
for( auto &vertex : shape.m_data.vertices ) {
|
||||
@@ -1380,8 +1364,8 @@ basic_region::insert( lines_node Lines, scratch_data &Scratchpad ) {
|
||||
vertex.position = glm::rotateY<double>( vertex.position, rotation.y );
|
||||
}
|
||||
}
|
||||
if( ( false == Scratchpad.location.offset.empty() )
|
||||
&& ( Scratchpad.location.offset.top() != glm::dvec3( 0, 0, 0 ) ) ) {
|
||||
if( false == Scratchpad.location.offset.empty()
|
||||
&& Scratchpad.location.offset.top() != glm::dvec3(0, 0, 0) ) {
|
||||
// ...and move
|
||||
auto const &offset = Scratchpad.location.offset.top();
|
||||
for( auto &vertex : Lines.m_data.vertices ) {
|
||||
@@ -1424,8 +1408,8 @@ basic_region::find_vehicle( glm::dvec3 const &Point, float const Radius, bool co
|
||||
|
||||
for( auto *section : sectionlist ) {
|
||||
std::tie( foundvehicle, founddistance ) = section->find( Point, Radius, Onlycontrolled, Findbycoupler );
|
||||
if( ( foundvehicle != nullptr )
|
||||
&& ( founddistance < nearestdistance ) ) {
|
||||
if( foundvehicle != nullptr
|
||||
&& founddistance < nearestdistance ) {
|
||||
|
||||
std::tie( nearestvehicle, nearestdistance ) = std::tie( foundvehicle, founddistance );
|
||||
}
|
||||
@@ -1477,8 +1461,8 @@ basic_region::find_traction( glm::dvec3 const &Point, TTraction const *Other, in
|
||||
|
||||
for( auto *section : sectionlist ) {
|
||||
std::tie( tractionfound, endpointfound, distancefound ) = section->find( Point, Other, Currentdirection );
|
||||
if( ( tractionfound != nullptr )
|
||||
&& ( distancefound < distancenearest ) ) {
|
||||
if( tractionfound != nullptr
|
||||
&& distancefound < distancenearest ) {
|
||||
|
||||
std::tie( tractionnearest, endpointnearest, distancenearest ) = std::tie( tractionfound, endpointfound, distancefound );
|
||||
}
|
||||
@@ -1509,8 +1493,8 @@ basic_region::sections( glm::dvec3 const &Point, float const Radius ) {
|
||||
if( column >= EU07_REGIONSIDESECTIONCOUNT ) { break; }
|
||||
|
||||
auto *section { m_sections[ row * EU07_REGIONSIDESECTIONCOUNT + column ] };
|
||||
if( ( section != nullptr )
|
||||
&& ( glm::length2( section->area().center - Point ) <= sq( section->area().radius + padding + Radius ) ) ) {
|
||||
if( section != nullptr
|
||||
&& glm::length2(section->area().center - Point) <= sq(section->area().radius + padding + Radius) ) {
|
||||
|
||||
m_scratchpad.sections.emplace_back( section );
|
||||
}
|
||||
@@ -1524,8 +1508,7 @@ bool
|
||||
basic_region::point_inside( glm::dvec3 const &Location ) {
|
||||
|
||||
double const regionboundary = EU07_REGIONSIDESECTIONCOUNT / 2 * EU07_SECTIONSIZE;
|
||||
return ( ( Location.x > -regionboundary ) && ( Location.x < regionboundary )
|
||||
&& ( Location.z > -regionboundary ) && ( Location.z < regionboundary ) );
|
||||
return Location.x > -regionboundary && Location.x < regionboundary && Location.z > -regionboundary && Location.z < regionboundary;
|
||||
}
|
||||
|
||||
// trims provided shape to fit into a section, adds trimmed part at the end of provided list
|
||||
@@ -1544,12 +1527,12 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque<shape_node> &Shap
|
||||
auto z0 = EU07_SECTIONSIZE * std::floor( 0.001 * Shape.m_data.area.center.z ) - margin;
|
||||
auto z1 = z0 + EU07_SECTIONSIZE + margin * 2;
|
||||
|
||||
if( ( Shape.m_data.vertices[ 0 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 0 ].position.x <= x1 )
|
||||
&& ( Shape.m_data.vertices[ 0 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 0 ].position.z <= z1 )
|
||||
&& ( Shape.m_data.vertices[ 1 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 1 ].position.x <= x1 )
|
||||
&& ( Shape.m_data.vertices[ 1 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 1 ].position.z <= z1 )
|
||||
&& ( Shape.m_data.vertices[ 2 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 2 ].position.x <= x1 )
|
||||
&& ( Shape.m_data.vertices[ 2 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 2 ].position.z <= z1 ) ) {
|
||||
if( Shape.m_data.vertices[0].position.x >= x0 && Shape.m_data.vertices[0].position.x <= x1
|
||||
&& Shape.m_data.vertices[0].position.z >= z0 && Shape.m_data.vertices[0].position.z <= z1
|
||||
&& Shape.m_data.vertices[1].position.x >= x0 && Shape.m_data.vertices[1].position.x <= x1
|
||||
&& Shape.m_data.vertices[1].position.z >= z0 && Shape.m_data.vertices[1].position.z <= z1
|
||||
&& Shape.m_data.vertices[2].position.x >= x0 && Shape.m_data.vertices[2].position.x <= x1
|
||||
&& Shape.m_data.vertices[2].position.z >= z0 && Shape.m_data.vertices[2].position.z <= z1 ) {
|
||||
// trójkąt wystający mniej niż 200m z kw. kilometrowego jest do przyjęcia
|
||||
return false;
|
||||
}
|
||||
@@ -1649,17 +1632,13 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque<shape_node> &Shap
|
||||
Shape.m_data.vertices[ 1 ].set_from_z(
|
||||
Shape.m_data.vertices[ 0 ],
|
||||
Shape.m_data.vertices[ 1 ],
|
||||
( ( divide & 8 ) ?
|
||||
z1 :
|
||||
z0 ) );
|
||||
divide & 8 ? z1 : z0 );
|
||||
}
|
||||
else {
|
||||
Shape.m_data.vertices[ 1 ].set_from_x(
|
||||
Shape.m_data.vertices[ 0 ],
|
||||
Shape.m_data.vertices[ 1 ],
|
||||
( ( divide & 8 ) ?
|
||||
x1 :
|
||||
x0 ) );
|
||||
divide & 8 ? x1 : x0 );
|
||||
}
|
||||
newshape.m_data.vertices[ 0 ] = Shape.m_data.vertices[ 1 ]; // wierzchołek D jest wspólny
|
||||
break;
|
||||
@@ -1672,17 +1651,13 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque<shape_node> &Shap
|
||||
Shape.m_data.vertices[ 2 ].set_from_z(
|
||||
Shape.m_data.vertices[ 1 ],
|
||||
Shape.m_data.vertices[ 2 ],
|
||||
( ( divide & 8 ) ?
|
||||
z1 :
|
||||
z0 ) );
|
||||
divide & 8 ? z1 : z0 );
|
||||
}
|
||||
else {
|
||||
Shape.m_data.vertices[ 2 ].set_from_x(
|
||||
Shape.m_data.vertices[ 1 ],
|
||||
Shape.m_data.vertices[ 2 ],
|
||||
( ( divide & 8 ) ?
|
||||
x1 :
|
||||
x0 ) );
|
||||
divide & 8 ? x1 : x0 );
|
||||
}
|
||||
newshape.m_data.vertices[ 1 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek D jest wspólny
|
||||
break;
|
||||
@@ -1695,17 +1670,13 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque<shape_node> &Shap
|
||||
Shape.m_data.vertices[ 2 ].set_from_z(
|
||||
Shape.m_data.vertices[ 2 ],
|
||||
Shape.m_data.vertices[ 0 ],
|
||||
( ( divide & 8 ) ?
|
||||
z1 :
|
||||
z0 ) );
|
||||
divide & 8 ? z1 : z0 );
|
||||
}
|
||||
else {
|
||||
Shape.m_data.vertices[ 2 ].set_from_x(
|
||||
Shape.m_data.vertices[ 2 ],
|
||||
Shape.m_data.vertices[ 0 ],
|
||||
( ( divide & 8 ) ?
|
||||
x1 :
|
||||
x0 ) );
|
||||
divide & 8 ? x1 : x0 );
|
||||
}
|
||||
newshape.m_data.vertices[ 0 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek D jest wspólny
|
||||
break;
|
||||
|
||||
@@ -341,7 +341,7 @@ public:
|
||||
|
||||
//private:
|
||||
// types
|
||||
using cell_array = std::array<basic_cell, (EU07_SECTIONSIZE / EU07_CELLSIZE) * (EU07_SECTIONSIZE / EU07_CELLSIZE)>;
|
||||
using cell_array = std::array<basic_cell, EU07_SECTIONSIZE / EU07_CELLSIZE * (EU07_SECTIONSIZE / EU07_CELLSIZE)>;
|
||||
using shapenode_sequence = std::vector<shape_node>;
|
||||
// methods
|
||||
// provides access to section enclosing specified point
|
||||
|
||||
@@ -140,8 +140,8 @@ basic_editor::rotate( scene::basic_node *Node, glm::vec3 const &Angle, float con
|
||||
|
||||
// quantize resulting angle if requested and type of the node allows it
|
||||
// TBD, TODO: angle quantization for types other than instanced models
|
||||
if( ( Quantization > 0.f )
|
||||
&& ( typeid( *Node ) == typeid( TAnimModel ) ) ) {
|
||||
if( Quantization > 0.f
|
||||
&& typeid(*Node) == typeid(TAnimModel) ) {
|
||||
|
||||
auto const initialangle { static_cast<TAnimModel *>( Node )->Angles() };
|
||||
rotation += initialangle;
|
||||
|
||||
@@ -25,8 +25,8 @@ struct node_snapshot {
|
||||
Node->export_as_text( data ); } };
|
||||
};
|
||||
|
||||
inline bool operator==( node_snapshot const &Left, node_snapshot const &Right ) { return ( ( Left.node == Right.node ) && ( Left.data == Right.data ) ); }
|
||||
inline bool operator!=( node_snapshot const &Left, node_snapshot const &Right ) { return ( !( Left == Right ) ); }
|
||||
inline bool operator==( node_snapshot const &Left, node_snapshot const &Right ) { return Left.node == Right.node && Left.data == Right.data; }
|
||||
inline bool operator!=( node_snapshot const &Left, node_snapshot const &Right ) { return !(Left == Right); }
|
||||
|
||||
class basic_editor {
|
||||
|
||||
|
||||
@@ -50,9 +50,7 @@ void
|
||||
bounding_area::deserialize( std::istream &Input, bool const Preserveradius ) {
|
||||
|
||||
center = sn_utils::d_dvec3( Input );
|
||||
radius = ( Preserveradius ?
|
||||
std::max( radius, sn_utils::ld_float32( Input ) ) :
|
||||
sn_utils::ld_float32( Input ) );
|
||||
radius = Preserveradius ? std::max(radius, sn_utils::ld_float32(Input)) : sn_utils::ld_float32(Input);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,9 +71,7 @@ shape_node::shapenode_data::serialize( std::ostream &Output ) const {
|
||||
// NOTE: material handle is created dynamically on load
|
||||
sn_utils::s_str(
|
||||
Output,
|
||||
( material != null_handle ?
|
||||
GfxRenderer->Material( material )->GetName() :
|
||||
"" ) );
|
||||
material != null_handle ? GfxRenderer->Material(material)->GetName() : "" );
|
||||
lighting.serialize( Output );
|
||||
// geometry
|
||||
sn_utils::s_dvec3( Output, origin );
|
||||
@@ -152,10 +148,7 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
||||
// import common data
|
||||
m_name = Nodedata.name;
|
||||
m_data.rangesquared_min = Nodedata.range_min * Nodedata.range_min;
|
||||
m_data.rangesquared_max = (
|
||||
Nodedata.range_max >= 0.0 ?
|
||||
Nodedata.range_max * Nodedata.range_max :
|
||||
std::numeric_limits<double>::max() );
|
||||
m_data.rangesquared_max = Nodedata.range_max >= 0.0 ? Nodedata.range_max * Nodedata.range_max : std::numeric_limits<double>::max();
|
||||
|
||||
std::string token = Input.getToken<std::string>();
|
||||
if( token == "material" ) {
|
||||
@@ -201,30 +194,14 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
||||
|
||||
// determine way to proceed from the assigned diffuse texture
|
||||
// TBT, TODO: add methods to material manager to access these simpler
|
||||
auto const texturehandle = (
|
||||
m_data.material != null_handle ?
|
||||
GfxRenderer->Material( m_data.material )->GetTexture(0) :
|
||||
null_handle );
|
||||
auto const &texture = (
|
||||
texturehandle ?
|
||||
GfxRenderer->Texture( texturehandle ) :
|
||||
*ITexture::null_texture() ); // dirty workaround for lack of better api
|
||||
bool const clamps = (
|
||||
texturehandle ?
|
||||
contains( texture.get_traits(), 's' ) :
|
||||
false );
|
||||
bool const clampt = (
|
||||
texturehandle ?
|
||||
contains( texture.get_traits(), 't' ) :
|
||||
false );
|
||||
auto const texturehandle = m_data.material != null_handle ? GfxRenderer->Material(m_data.material)->GetTexture(0) : null_handle;
|
||||
auto const &texture = texturehandle ? GfxRenderer->Texture(texturehandle) : *ITexture::null_texture(); // dirty workaround for lack of better api
|
||||
bool const clamps = texturehandle ? contains(texture.get_traits(), 's') : false;
|
||||
bool const clampt = texturehandle ? contains(texture.get_traits(), 't') : false;
|
||||
|
||||
// remainder of legacy 'problend' system -- geometry assigned a texture with '@' in its name is treated as translucent, opaque otherwise
|
||||
if( texturehandle != null_handle ) {
|
||||
m_data.translucent = (
|
||||
( ( contains( texture.get_name(), '@' ) )
|
||||
&& ( true == texture.get_has_alpha() ) ) ?
|
||||
true :
|
||||
false );
|
||||
m_data.translucent = contains(texture.get_name(), '@') && true == texture.get_has_alpha() ? true : false;
|
||||
}
|
||||
else {
|
||||
m_data.translucent = false;
|
||||
@@ -237,10 +214,7 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
||||
triangle_fan
|
||||
};
|
||||
|
||||
subtype const nodetype = (
|
||||
Nodedata.type == "triangles" ? triangles :
|
||||
Nodedata.type == "triangle_strip" ? triangle_strip :
|
||||
triangle_fan );
|
||||
subtype const nodetype = Nodedata.type == "triangles" ? triangles : Nodedata.type == "triangle_strip" ? triangle_strip : triangle_fan;
|
||||
std::size_t vertexcount{ 0 };
|
||||
world_vertex vertex, vertex1, vertex2;
|
||||
do {
|
||||
@@ -349,7 +323,7 @@ shape_node::convert( TSubModel const *Submodel ) {
|
||||
m_data.lighting.diffuse = Submodel->f4Diffuse;
|
||||
m_data.lighting.specular = Submodel->f4Specular;
|
||||
m_data.material = Submodel->m_material;
|
||||
m_data.translucent = ( GfxRenderer->Material( m_data.material )->get_or_guess_opacity() == 0.0f );
|
||||
m_data.translucent = GfxRenderer->Material(m_data.material)->get_or_guess_opacity() == 0.0f;
|
||||
// NOTE: we set unlimited view range typical for terrain, because we don't expect to convert any other 3d models
|
||||
m_data.rangesquared_max = std::numeric_limits<double>::max();
|
||||
|
||||
@@ -453,8 +427,8 @@ shape_node::make_terrain( material_handle const Material, std::vector<world_vert
|
||||
bool
|
||||
shape_node::merge( shape_node &Shape ) {
|
||||
|
||||
if( ( m_data.material != Shape.m_data.material )
|
||||
|| ( m_data.lighting != Shape.m_data.lighting ) ) {
|
||||
if( m_data.material != Shape.m_data.material
|
||||
|| m_data.lighting != Shape.m_data.lighting ) {
|
||||
// can't merge nodes with different appearance
|
||||
return false;
|
||||
}
|
||||
@@ -589,10 +563,7 @@ lines_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
||||
// import common data
|
||||
m_name = Nodedata.name;
|
||||
m_data.rangesquared_min = Nodedata.range_min * Nodedata.range_min;
|
||||
m_data.rangesquared_max = (
|
||||
Nodedata.range_max >= 0.0 ?
|
||||
Nodedata.range_max * Nodedata.range_max :
|
||||
std::numeric_limits<double>::max() );
|
||||
m_data.rangesquared_max = Nodedata.range_max >= 0.0 ? Nodedata.range_max * Nodedata.range_max : std::numeric_limits<double>::max();
|
||||
|
||||
// material
|
||||
Input.getTokens( 3, false );
|
||||
@@ -614,10 +585,7 @@ lines_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
||||
line_loop
|
||||
};
|
||||
|
||||
subtype const nodetype = (
|
||||
Nodedata.type == "lines" ? lines :
|
||||
Nodedata.type == "line_strip" ? line_strip :
|
||||
line_loop );
|
||||
subtype const nodetype = Nodedata.type == "lines" ? lines : Nodedata.type == "line_strip" ? line_strip : line_loop;
|
||||
std::size_t vertexcount { 0 };
|
||||
world_vertex vertex, vertex0, vertex1;
|
||||
std::string token = Input.getToken<std::string>();
|
||||
@@ -661,8 +629,8 @@ lines_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
||||
|
||||
} while( token != "endline" );
|
||||
// add closing line for the loop
|
||||
if( ( nodetype == line_loop )
|
||||
&& ( vertexcount > 2 ) ) {
|
||||
if( nodetype == line_loop
|
||||
&& vertexcount > 2 ) {
|
||||
m_data.vertices.emplace_back( vertex1 );
|
||||
m_data.vertices.emplace_back( vertex0 );
|
||||
}
|
||||
@@ -678,8 +646,8 @@ lines_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
||||
bool
|
||||
lines_node::merge( lines_node &Lines ) {
|
||||
|
||||
if( ( m_data.line_width != Lines.m_data.line_width )
|
||||
|| ( m_data.lighting != Lines.m_data.lighting ) ) {
|
||||
if( m_data.line_width != Lines.m_data.line_width
|
||||
|| m_data.lighting != Lines.m_data.lighting ) {
|
||||
// can't merge nodes with different appearance
|
||||
return false;
|
||||
}
|
||||
@@ -754,10 +722,7 @@ basic_node::basic_node( scene::node_data const &Nodedata ) :
|
||||
uuid = UID::random();
|
||||
node_type = Nodedata.type;
|
||||
m_rangesquaredmin = Nodedata.range_min * Nodedata.range_min;
|
||||
m_rangesquaredmax = (
|
||||
Nodedata.range_max >= 0.0 ?
|
||||
Nodedata.range_max * Nodedata.range_max :
|
||||
std::numeric_limits<double>::max() );
|
||||
m_rangesquaredmax = Nodedata.range_max >= 0.0 ? Nodedata.range_max * Nodedata.range_max : std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
// sends content of the class to provided stream
|
||||
|
||||
@@ -34,9 +34,7 @@ struct lighting_data {
|
||||
inline
|
||||
bool
|
||||
operator==( lighting_data const &Left, lighting_data const &Right ) {
|
||||
return ( ( Left.diffuse == Right.diffuse )
|
||||
&& ( Left.ambient == Right.ambient )
|
||||
&& ( Left.specular == Right.specular ) );
|
||||
return Left.diffuse == Right.diffuse && Left.ambient == Right.ambient && Left.specular == Right.specular;
|
||||
}
|
||||
|
||||
inline
|
||||
|
||||
@@ -38,12 +38,12 @@ node_groups::close()
|
||||
auto const closinggroup { m_activegroup.top() };
|
||||
m_activegroup.pop();
|
||||
// if the completed group holds only one item and there's no chance more items will be added, disband it
|
||||
if( ( true == m_activegroup.empty() )
|
||||
|| ( m_activegroup.top() != closinggroup ) ) {
|
||||
if( true == m_activegroup.empty()
|
||||
|| m_activegroup.top() != closinggroup ) {
|
||||
|
||||
auto lookup { m_groupmap.find( closinggroup ) };
|
||||
if( ( lookup != m_groupmap.end() )
|
||||
&& ( ( lookup->second.nodes.size() + lookup->second.events.size() ) <= 1 ) ) {
|
||||
if( lookup != m_groupmap.end()
|
||||
&& lookup->second.nodes.size() + lookup->second.events.size() <= 1 ) {
|
||||
|
||||
erase( lookup );
|
||||
}
|
||||
@@ -92,7 +92,7 @@ bool node_groups::assign_cross_switch(map::track_switch& sw, std::string &sw_nam
|
||||
else
|
||||
pos = 3;
|
||||
|
||||
sw.preview[idx][pos] = ((pos_0 > pos_1) ? '0' : '1');
|
||||
sw.preview[idx][pos] = pos_0 > pos_1 ? '0' : '1';
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -231,10 +231,7 @@ node_groups::update_map()
|
||||
group_handle
|
||||
node_groups::handle() const {
|
||||
|
||||
return (
|
||||
m_activegroup.empty() ?
|
||||
null_handle :
|
||||
m_activegroup.top() );
|
||||
return m_activegroup.empty() ? null_handle : m_activegroup.top();
|
||||
}
|
||||
|
||||
// places provided node in specified group
|
||||
@@ -279,8 +276,8 @@ node_groups::export_as_text( std::ostream &Output, bool Dirty ) const {
|
||||
continue;
|
||||
// HACK: auto-generated memory cells aren't exported, so we check for this
|
||||
// TODO: is_exportable as basic_node method
|
||||
if( ( typeid( *node ) == typeid( TMemCell ) )
|
||||
&& ( false == static_cast<TMemCell *>( node )->is_exportable ) ) {
|
||||
if( typeid(*node) == typeid(TMemCell)
|
||||
&& false == static_cast<TMemCell *>(node)->is_exportable ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -322,10 +319,8 @@ node_groups::erase( group_map::const_iterator Group ) {
|
||||
group_handle
|
||||
node_groups::create_handle() {
|
||||
// NOTE: for simplification nested group structure are flattened
|
||||
return(
|
||||
m_activegroup.empty() ?
|
||||
m_groupmap.size() + 1 : // new group isn't created until node registration
|
||||
m_activegroup.top() );
|
||||
return m_activegroup.empty() ? m_groupmap.size() + 1 : // new group isn't created until node registration
|
||||
m_activegroup.top();
|
||||
}
|
||||
|
||||
} // scene
|
||||
|
||||
@@ -16,7 +16,7 @@ uint16_t sn_utils::ld_uint16(std::istream &s)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
s.read((char*)buf, 2);
|
||||
uint16_t v = (buf[1] << 8) | buf[0];
|
||||
uint16_t v = buf[1] << 8 | buf[0];
|
||||
return reinterpret_cast<uint16_t&>(v);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ uint32_t sn_utils::ld_uint32(std::istream &s)
|
||||
{
|
||||
uint8_t buf[4];
|
||||
s.read((char*)buf, 4);
|
||||
uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
|
||||
uint32_t v = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
|
||||
return reinterpret_cast<uint32_t&>(v);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ int32_t sn_utils::ld_int32(std::istream &s)
|
||||
{
|
||||
uint8_t buf[4];
|
||||
s.read((char*)buf, 4);
|
||||
uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
|
||||
uint32_t v = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
|
||||
return reinterpret_cast<int32_t&>(v);
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ uint64_t sn_utils::ld_uint64(std::istream &s)
|
||||
{
|
||||
uint8_t buf[8];
|
||||
s.read((char*)buf, 8);
|
||||
uint64_t v = ((uint64_t)buf[7] << 56) | ((uint64_t)buf[6] << 48) |
|
||||
((uint64_t)buf[5] << 40) | ((uint64_t)buf[4] << 32) |
|
||||
((uint64_t)buf[3] << 24) | ((uint64_t)buf[2] << 16) |
|
||||
((uint64_t)buf[1] << 8) | (uint64_t)buf[0];
|
||||
uint64_t v = (uint64_t)buf[7] << 56 | (uint64_t)buf[6] << 48 |
|
||||
(uint64_t)buf[5] << 40 | (uint64_t)buf[4] << 32 |
|
||||
(uint64_t)buf[3] << 24 | (uint64_t)buf[2] << 16 |
|
||||
(uint64_t)buf[1] << 8 | (uint64_t)buf[0];
|
||||
return reinterpret_cast<uint64_t&>(v);
|
||||
}
|
||||
|
||||
@@ -55,10 +55,10 @@ int64_t sn_utils::ld_int64(std::istream &s)
|
||||
{
|
||||
uint8_t buf[8];
|
||||
s.read((char*)buf, 8);
|
||||
uint64_t v = ((uint64_t)buf[7] << 56) | ((uint64_t)buf[6] << 48) |
|
||||
((uint64_t)buf[5] << 40) | ((uint64_t)buf[4] << 32) |
|
||||
((uint64_t)buf[3] << 24) | ((uint64_t)buf[2] << 16) |
|
||||
((uint64_t)buf[1] << 8) | (uint64_t)buf[0];
|
||||
uint64_t v = (uint64_t)buf[7] << 56 | (uint64_t)buf[6] << 48 |
|
||||
(uint64_t)buf[5] << 40 | (uint64_t)buf[4] << 32 |
|
||||
(uint64_t)buf[3] << 24 | (uint64_t)buf[2] << 16 |
|
||||
(uint64_t)buf[1] << 8 | (uint64_t)buf[0];
|
||||
return reinterpret_cast<int64_t&>(v);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ float sn_utils::ld_float32(std::istream &s)
|
||||
{
|
||||
uint8_t buf[4];
|
||||
s.read((char*)buf, 4);
|
||||
uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
|
||||
uint32_t v = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
|
||||
return reinterpret_cast<float&>(v);
|
||||
}
|
||||
|
||||
@@ -76,10 +76,10 @@ double sn_utils::ld_float64(std::istream &s)
|
||||
{
|
||||
uint8_t buf[8];
|
||||
s.read((char*)buf, 8);
|
||||
uint64_t v = ((uint64_t)buf[7] << 56) | ((uint64_t)buf[6] << 48) |
|
||||
((uint64_t)buf[5] << 40) | ((uint64_t)buf[4] << 32) |
|
||||
((uint64_t)buf[3] << 24) | ((uint64_t)buf[2] << 16) |
|
||||
((uint64_t)buf[1] << 8) | (uint64_t)buf[0];
|
||||
uint64_t v = (uint64_t)buf[7] << 56 | (uint64_t)buf[6] << 48 |
|
||||
(uint64_t)buf[5] << 40 | (uint64_t)buf[4] << 32 |
|
||||
(uint64_t)buf[3] << 24 | (uint64_t)buf[2] << 16 |
|
||||
(uint64_t)buf[1] << 8 | (uint64_t)buf[0];
|
||||
return reinterpret_cast<double&>(v);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ std::string sn_utils::d_str(std::istream &s)
|
||||
|
||||
bool sn_utils::d_bool(std::istream& s)
|
||||
{
|
||||
return ( ld_uint16( s ) == 1 );
|
||||
return ld_uint16(s) == 1;
|
||||
}
|
||||
|
||||
glm::dvec3 sn_utils::d_dvec3(std::istream& s)
|
||||
@@ -234,9 +234,7 @@ void sn_utils::s_bool(std::ostream &s, bool v)
|
||||
{
|
||||
ls_uint16(
|
||||
s,
|
||||
( true == v ?
|
||||
1 :
|
||||
0 ) );
|
||||
true == v ? 1 : 0 );
|
||||
}
|
||||
|
||||
void sn_utils::s_dvec3(std::ostream &s, glm::dvec3 const &v)
|
||||
|
||||
Reference in New Issue
Block a user