17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 17:26:22 +01:00

Merge branch 'master' into feat/renderers-cleanup

This commit is contained in:
2026-11-07 16:44:51 +01:00
177 changed files with 11657 additions and 833 deletions

View File

@@ -431,6 +431,15 @@ geometry_bank::type( gfx::geometry_handle const &Geometry ) const {
return geometry_bank::chunk( Geometry ).type;
}
// kind of geometry of specified chunk
unsigned int
geometry_bank::primitive( gfx::geometry_handle const &Geometry ) const {
if( ( Geometry.chunk == 0 ) || ( Geometry.chunk > m_chunks.size() ) ) { return no_primitive; }
return geometry_bank::chunk( Geometry ).type;
}
// provides direct access to vertex user data of specfied chunk
userdata_array const &
geometry_bank::userdata( gfx::geometry_handle const &Geometry ) const {
@@ -659,6 +668,15 @@ geometrybank_manager::type( gfx::geometry_handle const &Geometry ) const {
return bank( Geometry ).first->type( Geometry );
}
// kind of geometry of specified chunk
unsigned int
geometrybank_manager::primitive( gfx::geometry_handle const &Geometry ) const {
if( ( Geometry.bank == 0 ) || ( Geometry.bank > m_geometrybanks.size() ) ) { return geometry_bank::no_primitive; }
return bank( Geometry ).first->primitive( Geometry );
}
// provides direct access to vertex user data of specfied chunk
gfx::userdata_array const &
geometrybank_manager::userdata( gfx::geometry_handle const &Geometry ) const {

View File

@@ -170,6 +170,9 @@ public:
// what the chunks keep in the process (a copy of what went to the gpu), added to the counts: chunks and vertex bytes, index bytes,
// user data bytes
void count_memory( memory_count &Vertices, memory_count &Indices, memory_count &Userdata ) const;
// kind of geometry of specified chunk, GL_TRIANGLES, GL_TRIANGLE_STRIP...; no_primitive for a handle to no chunk
auto primitive( gfx::geometry_handle const &Geometry ) const -> unsigned int;
static constexpr unsigned int no_primitive { ~0u };
protected:
// types:
@@ -302,6 +305,8 @@ public:
auto userdata( gfx::geometry_handle const &Geometry ) const -> gfx::userdata_array const &;
// primitive type of specified chunk, 0 if there's no such chunk
auto type( gfx::geometry_handle const &Geometry ) const -> unsigned int;
// kind of geometry of specified chunk
auto primitive( gfx::geometry_handle const &Geometry ) const -> unsigned int;
// sets target texture unit for the texture data stream
auto units() -> gfx::stream_units & { return m_units; }
// provides access to primitives count

View File

@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "model/AnimModel.h"
#include "simulation/simulationenvironment.h"
#include "utilities/Logs.h"
#include "vehicle/smoke.h"
void
@@ -169,53 +170,32 @@ smoke_source::bind( TAnimModel const *Node ) {
void
smoke_source::accumulate_spawns( double const Timedelta, bool const Onlydespawn ) {
m_spawncount = (
( ( false == Global.Smoke ) || ( true == Onlydespawn ) ) ?
0.f :
std::min<float>(
static_cast<float>(m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity )),
static_cast<float>(m_max_particles) ) );
// consider special spawn rate cases
auto const spawning { ( true == Global.Smoke ) && ( false == Onlydespawn ) };
if( m_ownertype == owner_type::vehicle ) {
if (Global.AirTemperature <= 5.f || m_owner.vehicle->MoverParameters->dizel_heat.Ts < 45.f)
{
m_emitter.color = glm::vec3{128, 128, 128};
}
if (m_owner.vehicle->MoverParameters->dizel_spinup == true)
{
m_spawncount =
((false == Global.Smoke) || (true == Onlydespawn)) ?
0.f :
std::min<float>(
// m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity ),
static_cast<float>(m_spawncount +(m_spawnrate * Timedelta * Global.SmokeFidelity * (((m_owner.vehicle->MoverParameters->enrot) / 4 ) * 0.01))), static_cast<float>(m_max_particles));
}
else
{
if (m_owner.vehicle->MoverParameters->DirAbsolute == 0 ||
m_owner.vehicle->MoverParameters->Im == 0)
{
m_spawncount =
((false == Global.Smoke) || (true == Onlydespawn)) ?
0.f :
std::min<float>(
// m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity ),
static_cast<float>(m_spawncount + (m_spawnrate * Timedelta * Global.SmokeFidelity * ((((m_owner.vehicle->MoverParameters->DElist[m_owner.vehicle->MoverParameters->MainCtrlPosNo].RPM -m_owner.vehicle->MoverParameters->enrot) /60) *0.02) *(m_owner.vehicle->MoverParameters->EnginePower * 0.005)))), static_cast<float>(m_max_particles));
}
else
{
m_spawncount =
((false == Global.Smoke) || (true == Onlydespawn)) ?
0.f :
std::min<float>(
// m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity ),
static_cast<float>(m_spawncount + (m_spawnrate * Timedelta * Global.SmokeFidelity * ((((m_owner.vehicle->MoverParameters->DElist[m_owner.vehicle->MoverParameters->MainCtrlPosNo].RPM -m_owner.vehicle->MoverParameters->enrot) /60) * (sqrt(m_owner.vehicle->MoverParameters->Im) * 0.01) * 0.02) *(m_owner.vehicle->MoverParameters->EnginePower * 0.005)))), static_cast<float>(m_max_particles));
}
}
}
auto const &mover { *m_owner.vehicle->MoverParameters };
if( Global.AirTemperature <= 5.f || mover.dizel_heat.Ts < 45.f ) {
m_emitter.color = glm::vec3{ 128, 128, 128 };
}
// a vehicle taken off the tracks (gone through a portal, or waiting in the pool of the road traffic) puffs no more,
// the particles it already let out fade away as usual
m_spawncount = (
( true == spawning ) ?
smoke::vehicle_spawn_count(
mover, m_owner.vehicle->bEnabled,
{ m_spawncount, m_spawnrate, Global.SmokeFidelity, static_cast<float>( m_max_particles ) },
Timedelta ) :
0.f );
}
else {
m_spawncount = (
( true == spawning ) ?
std::min<float>(
static_cast<float>(m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity )),
static_cast<float>(m_max_particles) ) :
0.f );
}
}
// updates state of owned particles

View File

@@ -96,7 +96,10 @@ public:
virtual auto Replace_Indexed( gfx::index_array &Indices, gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometry_handle const &Geometry ) -> bool { return false; }
// adds supplied vertex data at the end of specified chunk
virtual auto Append(gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometry_handle const &Geometry, int const Type) -> bool = 0;
virtual void Erase( gfx::geometry_handle const &Geometry ) {}
// empties specified chunk, its handle stays valid to be filled again
virtual void Erase( gfx::geometry_handle const & /*Geometry*/ ) {
// a renderer which keeps no chunks of its own has none to empty
}
// provides direct access to index data of specfied chunk
virtual auto Indices( gfx::geometry_handle const &Geometry ) const->gfx::index_array const & = 0;
// provides direct access to vertex data of specfied chunk
@@ -111,6 +114,7 @@ public:
virtual auto Material( material_handle const Material ) const -> IMaterial const * = 0;
// the same material with its highlights damped, for faces which aren't polished like the surfaces they are cut from. backends which can't make one give back the material itself
virtual auto Matte_Material( material_handle const Material ) -> material_handle { return Material; }
// the same material with its texture tinted by the colour, as far as the userdata of the vertices says. backends which can't make one give back the material itself
virtual auto Tinted_Material( material_handle const Material, glm::vec3 const &Colour ) -> material_handle { return Material; }
// the material of a track blending its texture with those of up to three others (null: none) by the weights in y, z and w of the user data
// of the vertices (world/TrackBlend.h). backends which can't make one give back the material itself
@@ -147,7 +151,10 @@ public:
virtual void Pick_Node_Callback( std::function<void( scene::basic_node * )> Callback ) = 0;
virtual auto Pick_Control() const -> TSubModel const * = 0;
virtual auto Pick_Node() const -> scene::basic_node const * = 0;
virtual void Forget_Node( scene::basic_node const *Node ) {}
// a node deleted from the scene is no longer given as picked
virtual void Forget_Node( scene::basic_node const * /*Node*/ ) {
// a renderer which keeps no node picked has none to forget
}
virtual auto Mouse_Position() const -> glm::dvec3 = 0;
virtual auto Mouse_Hit() const -> bool { return true; }