Merge branch 'tmj-dev' into milek-dev

This commit is contained in:
milek7
2018-05-19 20:26:01 +02:00
40 changed files with 1103 additions and 537 deletions

View File

@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "PyInt.h"
#include "Globals.h"
#include "parser.h"
#include "renderer.h"
#include "Model3d.h"
@@ -456,6 +457,7 @@ void TPythonScreens::init(cParser &parser, TModel3d *model, std::string const &n
WriteLog( "Python Screen: null renderer for " + pyClassName + " - Ignoring screen" );
return; // nie mozna utworzyc obiektu Pythonowego
}
m_updaterate = Global.PythonScreenUpdateRate;
TPythonScreenRenderer *renderer = new TPythonScreenRenderer(textureId, pyRenderer);
_screens.push_back(renderer);
WriteLog( "Created python screen " + pyClassName + " on submodel " + subModelName + " (" + std::to_string(textureId) + ")" );
@@ -484,10 +486,6 @@ void TPythonScreens::setLookupPath(std::string const &path)
TPythonScreens::TPythonScreens()
{
TPythonInterpreter::getInstance()->loadClassFile("", "abstractscreenrenderer");
_terminationFlag = false;
_renderReadyFlag = false;
_cleanupReadyFlag = false;
_thread = NULL;
}
TPythonScreens::~TPythonScreens()
@@ -511,6 +509,7 @@ void TPythonScreens::run()
{
while (1)
{
m_updatestopwatch.start();
if (_terminationFlag)
{
return;
@@ -534,12 +533,17 @@ void TPythonScreens::run()
return;
}
_renderReadyFlag = true;
m_updatestopwatch.stop();
while (!_cleanupReadyFlag && !_terminationFlag)
{
auto const sleeptime {
std::max(
100,
m_updaterate - static_cast<int>( m_updatestopwatch.average() ) ) };
#ifdef _WIN32
Sleep(100);
Sleep( sleeptime );
#elif __linux__
usleep(100*1000);
usleep( sleeptime * 1000 );
#endif
}
if (_terminationFlag)
@@ -552,7 +556,7 @@ void TPythonScreens::run()
void TPythonScreens::finish()
{
_thread = NULL;
// nothing to do here, proper clean up takes place afterwards
}
void ScreenRendererThread(TPythonScreens* renderer)