2002-10-12 11:37:38 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
* The engine ties all game modules together.
|
|
|
|
*/
|
2002-11-25 15:29:57 +00:00
|
|
|
|
2011-02-25 13:35:59 +00:00
|
|
|
/** \file gameengine/Ketsji/KX_KetsjiEngine.cpp
|
|
|
|
* \ingroup ketsji
|
|
|
|
*/
|
|
|
|
|
2012-10-15 02:15:07 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma warning (disable:4786)
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
2011-03-09 01:25:59 +00:00
|
|
|
#include <stdio.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-04-06 23:30:59 +00:00
|
|
|
#include "BLI_task.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "KX_KetsjiEngine.h"
|
|
|
|
|
|
|
|
#include "ListValue.h"
|
|
|
|
#include "IntValue.h"
|
|
|
|
#include "VectorValue.h"
|
|
|
|
#include "BoolValue.h"
|
|
|
|
#include "FloatValue.h"
|
|
|
|
|
|
|
|
#include "RAS_BucketManager.h"
|
|
|
|
#include "RAS_Rect.h"
|
|
|
|
#include "RAS_IRasterizer.h"
|
|
|
|
#include "RAS_ICanvas.h"
|
2014-03-28 05:32:06 +00:00
|
|
|
#include "RAS_ILightObject.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MT_Vector3.h"
|
|
|
|
#include "MT_Transform.h"
|
|
|
|
#include "SCA_IInputDevice.h"
|
|
|
|
#include "KX_Camera.h"
|
2009-04-08 15:06:20 +00:00
|
|
|
#include "KX_Dome.h"
|
2008-07-10 12:47:20 +00:00
|
|
|
#include "KX_Light.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "KX_PythonInit.h"
|
|
|
|
#include "KX_PyConstraintBinding.h"
|
|
|
|
#include "PHY_IPhysicsEnvironment.h"
|
2009-02-25 12:07:51 +00:00
|
|
|
|
2011-06-23 09:27:56 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
|
|
|
# include "AUD_C-API.h"
|
2011-08-07 11:54:58 +00:00
|
|
|
# include "AUD_I3DDevice.h"
|
2011-06-23 09:27:56 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "NG_NetworkScene.h"
|
|
|
|
#include "NG_NetworkDeviceInterface.h"
|
|
|
|
|
|
|
|
#include "KX_WorldInfo.h"
|
|
|
|
#include "KX_ISceneConverter.h"
|
|
|
|
#include "KX_TimeCategoryLogger.h"
|
|
|
|
|
|
|
|
#include "RAS_FramingManager.h"
|
2009-05-21 18:10:19 +00:00
|
|
|
#include "DNA_world_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-05-31 22:35:22 +00:00
|
|
|
#include "KX_NavMeshObject.h"
|
2010-05-19 01:42:17 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// If define: little test for Nzc: guarded drawing. If the canvas is
|
|
|
|
// not valid, skip rendering this frame.
|
|
|
|
//#define NZC_GUARDED_OUTPUT
|
2006-05-10 02:04:21 +00:00
|
|
|
#define DEFAULT_LOGIC_TIC_RATE 60.0
|
2013-01-11 03:21:24 +00:00
|
|
|
//#define DEFAULT_PHYSICS_TIC_RATE 60.0
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-04-29 00:44:49 +00:00
|
|
|
#ifdef FREE_WINDOWS /* XXX mingw64 (gcc 4.7.0) defines a macro for DrawText that translates to DrawTextA. Not good */
|
|
|
|
#ifdef DrawText
|
|
|
|
#undef DrawText
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
|
|
|
|
"Physics:", // tc_physics
|
2011-07-14 07:03:33 +00:00
|
|
|
"Logic:", // tc_logic
|
|
|
|
"Animations:", // tc_animations
|
2002-10-12 11:37:38 +00:00
|
|
|
"Network:", // tc_network
|
|
|
|
"Scenegraph:", // tc_scenegraph
|
|
|
|
"Rasterizer:", // tc_rasterizer
|
|
|
|
"Services:", // tc_services
|
|
|
|
"Overhead:", // tc_overhead
|
2013-08-13 03:09:58 +00:00
|
|
|
"Outside:", // tc_outside
|
|
|
|
"GPU Latency:" // tc_latency
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
double KX_KetsjiEngine::m_ticrate = DEFAULT_LOGIC_TIC_RATE;
|
2009-05-01 16:35:06 +00:00
|
|
|
int KX_KetsjiEngine::m_maxLogicFrame = 5;
|
2009-05-21 18:10:19 +00:00
|
|
|
int KX_KetsjiEngine::m_maxPhysicsFrame = 5;
|
2008-06-17 10:06:38 +00:00
|
|
|
double KX_KetsjiEngine::m_anim_framerate = 25.0;
|
2005-12-18 19:10:26 +00:00
|
|
|
double KX_KetsjiEngine::m_suspendedtime = 0.0;
|
|
|
|
double KX_KetsjiEngine::m_suspendeddelta = 0.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
double KX_KetsjiEngine::m_average_framerate = 0.0;
|
2011-08-12 20:53:29 +00:00
|
|
|
bool KX_KetsjiEngine::m_restrict_anim_fps = false;
|
Cucumber, first batch of merge - UI changes and custom exit key
---------------------------------------------------------------
This was a test drive to see how painful the merge will be.
Next batches are:
- use desktop option for fullscreen
- multisampling option
- bullet collision mask
- python
- storage (vbo, dl, ...)
- lighting
[lighting still needs review]
[python could use review, although it should be straightforward]
[storage should be tested more I think]
Merged /branches/soc-2011-cucumber:r
36991,37059,37157,37416,37497-37499,37501,37522,39036,40593
36991:
==UI==
* Made some options available in Blender Game that were only available in Blender Render (camera resolution, animation fps)
* Created a panel for the embedded player
* Renamed the FPS option for the standalone player to Refresh Rate
* Moved framing options to display
* Made a button to launch the blender player from within blender (only tested on windows for now)
37059:
==UI==
* Added the option to change the exit key for the BGE. The UI currently just sets a number, and this feature most likely does not work for blenderplayer yet. More work on this to come.
* Removed the physics settings from the scene panel for the BGE.
* Added an Add menu in the logic brick header.
37157:
Making the bake options available in Blender Game
37416:
Making the exit key UI element accept key presses instead of numbers. It still does not work for the Blenderplayer, and it does not limit the input to key presses (other events don't work for exiting)
37497:
Some more work on getting the exit key to work in the Blenderplayer.
Input is now restricted to keyboard events only for the exit key UI.
37498:
Some clean up from the last commit.
The exit key setting affects the Blenderplayer now.
37499:
Cleaning up some duplicate code. Now the reverseTranslateTable for converting blender key codes to ketsji key codes is only defined in BL_BlenderDataConverter.
37501:
Centralizing the exit key methods to the keyboard devices. This should make it easier to get exit key control to the python API.
[37517: committed previously]
37522:
Moved control of the exit key away from the keyboard devices, and moved it to ketsjiengine.
Added setExitKey and getExitKey to the python API
39036:
A couple of the doversions were in the wrong spot. This should fix some issues with the exit key not being set.
[not committed entirely, see below]]
40552: space_logic.py (* fixed an error in space_logic.py *)
40593:
launch blenderplayer from ui not working in OSX fix - by Daniel Stokes and me
########################################################
code left behind (to be included in next commit):
########################################################
{
/* Initialize default values for collision masks */
Object *ob;
for(ob=main->object.first; ob; ob=ob->id.next)
ob->col_group = ob->col_mask = 1;
}
2011-12-20 03:11:56 +00:00
|
|
|
short KX_KetsjiEngine::m_exitkey = 130; //ESC Key
|
2005-12-18 19:10:26 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor of the Ketsji Engine
|
|
|
|
*/
|
|
|
|
KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
|
2011-09-01 02:12:53 +00:00
|
|
|
: m_canvas(NULL),
|
2004-03-22 22:02:18 +00:00
|
|
|
m_rasterizer(NULL),
|
2004-10-16 11:41:50 +00:00
|
|
|
m_kxsystem(system),
|
|
|
|
m_sceneconverter(NULL),
|
|
|
|
m_networkdevice(NULL),
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2004-10-16 11:41:50 +00:00
|
|
|
m_pythondictionary(NULL),
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
2004-10-16 11:41:50 +00:00
|
|
|
m_keyboarddevice(NULL),
|
|
|
|
m_mousedevice(NULL),
|
|
|
|
|
2004-03-22 22:02:18 +00:00
|
|
|
m_bInitialized(false),
|
2004-10-16 11:41:50 +00:00
|
|
|
m_activecam(0),
|
|
|
|
m_bFixedTime(false),
|
|
|
|
|
|
|
|
m_firstframe(true),
|
|
|
|
|
2006-01-12 06:30:01 +00:00
|
|
|
m_frameTime(0.f),
|
|
|
|
m_clockTime(0.f),
|
|
|
|
m_previousClockTime(0.f),
|
2011-07-14 07:03:33 +00:00
|
|
|
m_previousAnimTime(0.f),
|
2006-01-12 06:30:01 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
m_exitcode(KX_EXIT_REQUEST_NO_REQUEST),
|
|
|
|
m_exitstring(""),
|
2014-03-25 03:11:11 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
m_cameraZoom(1.0),
|
|
|
|
|
|
|
|
m_overrideCam(false),
|
|
|
|
m_overrideCamUseOrtho(false),
|
2008-09-15 00:11:30 +00:00
|
|
|
m_overrideCamNear(0.0),
|
|
|
|
m_overrideCamFar(0.0),
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
m_stereo(false),
|
|
|
|
m_curreye(0),
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
m_logger(NULL),
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// Set up timing info display variables
|
2004-10-16 11:41:50 +00:00
|
|
|
m_show_framerate(false),
|
|
|
|
m_show_profile(false),
|
|
|
|
m_showProperties(false),
|
|
|
|
m_showBackground(false),
|
|
|
|
m_show_debug_properties(false),
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-02-22 12:25:58 +00:00
|
|
|
m_animation_record(false),
|
2008-07-29 15:48:31 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// Default behavior is to hide the cursor every frame.
|
2004-10-16 11:41:50 +00:00
|
|
|
m_hideCursor(false),
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
m_overrideFrameColor(false),
|
|
|
|
m_overrideFrameColorR(0.0),
|
|
|
|
m_overrideFrameColorG(0.0),
|
2009-04-23 13:30:34 +00:00
|
|
|
m_overrideFrameColorB(0.0),
|
|
|
|
|
|
|
|
m_usedome(false)
|
2004-10-16 11:41:50 +00:00
|
|
|
{
|
|
|
|
// Initialize the time logger
|
|
|
|
m_logger = new KX_TimeCategoryLogger (25);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
for (int i = tc_first; i < tc_numCategories; i++)
|
|
|
|
m_logger->AddCategory((KX_TimeCategory)i);
|
2013-03-19 04:51:37 +00:00
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
m_pyprofiledict = PyDict_New();
|
|
|
|
#endif
|
2014-03-25 03:11:11 +00:00
|
|
|
|
2014-04-06 23:30:59 +00:00
|
|
|
m_taskscheduler = BLI_task_scheduler_create(TASK_SCHEDULER_AUTO_THREADS);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor of the Ketsji Engine, release all memory
|
|
|
|
*/
|
|
|
|
KX_KetsjiEngine::~KX_KetsjiEngine()
|
|
|
|
{
|
2004-10-16 11:41:50 +00:00
|
|
|
delete m_logger;
|
2012-03-24 07:52:14 +00:00
|
|
|
if (m_usedome)
|
2009-04-08 15:06:20 +00:00
|
|
|
delete m_dome;
|
2013-03-19 04:51:37 +00:00
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
Py_CLEAR(m_pyprofiledict);
|
|
|
|
#endif
|
2014-04-06 23:30:59 +00:00
|
|
|
|
|
|
|
if (m_taskscheduler)
|
|
|
|
BLI_task_scheduler_free(m_taskscheduler);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetKeyboardDevice(SCA_IInputDevice* keyboarddevice)
|
|
|
|
{
|
2005-03-25 10:33:39 +00:00
|
|
|
MT_assert(keyboarddevice);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_keyboarddevice = keyboarddevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetMouseDevice(SCA_IInputDevice* mousedevice)
|
|
|
|
{
|
2005-03-25 10:33:39 +00:00
|
|
|
MT_assert(mousedevice);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_mousedevice = mousedevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetNetworkDevice(NG_NetworkDeviceInterface* networkdevice)
|
|
|
|
{
|
2005-03-25 10:33:39 +00:00
|
|
|
MT_assert(networkdevice);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_networkdevice = networkdevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetCanvas(RAS_ICanvas* canvas)
|
|
|
|
{
|
2005-03-25 10:33:39 +00:00
|
|
|
MT_assert(canvas);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_canvas = canvas;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer)
|
|
|
|
{
|
2005-03-25 10:33:39 +00:00
|
|
|
MT_assert(rasterizer);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_rasterizer = rasterizer;
|
|
|
|
}
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2008-07-14 00:47:07 +00:00
|
|
|
/*
|
2010-08-11 12:14:16 +00:00
|
|
|
* At the moment the bge.logic module is imported into 'pythondictionary' after this function is called.
|
2008-07-14 00:47:07 +00:00
|
|
|
* if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand.
|
|
|
|
*/
|
2012-09-16 04:58:18 +00:00
|
|
|
void KX_KetsjiEngine::SetPyNamespace(PyObject *pythondictionary)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2005-03-25 10:33:39 +00:00
|
|
|
MT_assert(pythondictionary);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_pythondictionary = pythondictionary;
|
|
|
|
}
|
2013-03-19 04:51:37 +00:00
|
|
|
|
|
|
|
PyObject* KX_KetsjiEngine::GetPyProfileDict()
|
|
|
|
{
|
|
|
|
Py_INCREF(m_pyprofiledict);
|
|
|
|
return m_pyprofiledict;
|
|
|
|
}
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetSceneConverter(KX_ISceneConverter* sceneconverter)
|
|
|
|
{
|
2005-03-25 10:33:39 +00:00
|
|
|
MT_assert(sceneconverter);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_sceneconverter = sceneconverter;
|
|
|
|
}
|
|
|
|
|
2009-05-17 20:37:13 +00:00
|
|
|
void KX_KetsjiEngine::InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text)
|
2009-04-08 15:06:20 +00:00
|
|
|
{
|
2013-11-04 19:21:07 +00:00
|
|
|
m_dome = new KX_Dome(m_canvas, m_rasterizer,this, res, mode, angle, resbuf, tilt, text);
|
2009-04-08 15:06:20 +00:00
|
|
|
m_usedome = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::RenderDome()
|
|
|
|
{
|
2012-10-08 03:28:11 +00:00
|
|
|
const GLint *viewport = m_canvas->GetViewPort();
|
2009-04-08 15:06:20 +00:00
|
|
|
|
|
|
|
m_dome->SetViewPort(viewport);
|
|
|
|
|
|
|
|
KX_Scene* firstscene = *m_scenes.begin();
|
|
|
|
const RAS_FrameSettings &framesettings = firstscene->GetFramingType();
|
|
|
|
|
|
|
|
m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
|
|
|
|
// hiding mouse cursor each frame
|
|
|
|
// (came back when going out of focus and then back in again)
|
|
|
|
if (m_hideCursor)
|
|
|
|
m_canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
|
|
|
|
|
|
|
|
// clear the entire game screen with the border color
|
|
|
|
// only once per frame
|
|
|
|
|
|
|
|
m_canvas->BeginDraw();
|
|
|
|
|
|
|
|
// BeginFrame() sets the actual drawing area. You can use a part of the window
|
|
|
|
if (!BeginFrame())
|
|
|
|
return;
|
|
|
|
|
|
|
|
KX_SceneList::iterator sceneit;
|
2013-03-23 03:04:02 +00:00
|
|
|
KX_Scene* scene = NULL;
|
BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive
performance improvement in the culling and in the rasterizer when
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms) 2.48 1st round 3rd round
All objects static, 323.0 86.0 7.2
all visible, 1000 in
the view frustrum
All objects static, 219.0 49.7 N/A(*)
all invisible.
All objects moving, 323.0 105.6 34.7
all visible, 1000 in
the view frustrum
Scene destruction 40min 40min 4s
(*) : this time is not representative because the frame rate was at 60fps.
In that case, the GPU holds down the GE by frame sync. By design, the
overhead of the rasterizer is 0 when the the objects are invisible.
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
2009-05-07 09:13:01 +00:00
|
|
|
|
2009-04-13 20:08:33 +00:00
|
|
|
int n_renders=m_dome->GetNumberRenders();// usually 4 or 6
|
2012-03-28 05:03:24 +00:00
|
|
|
for (int i=0;i<n_renders;i++) {
|
2009-04-08 15:06:20 +00:00
|
|
|
m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER);
|
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
|
|
|
|
// for each scene, call the proceed functions
|
|
|
|
{
|
2010-03-28 10:20:26 +00:00
|
|
|
scene = *sceneit;
|
2009-04-08 15:06:20 +00:00
|
|
|
KX_Camera* cam = scene->GetActiveCamera();
|
|
|
|
|
|
|
|
// pass the scene's worldsettings to the rasterizer
|
|
|
|
SetWorldSettings(scene->GetWorldInfo());
|
|
|
|
|
|
|
|
// shadow buffers
|
2012-03-28 05:03:24 +00:00
|
|
|
if (i == 0) {
|
2009-04-08 15:06:20 +00:00
|
|
|
RenderShadowBuffers(scene);
|
|
|
|
}
|
|
|
|
// Avoid drawing the scene with the active camera twice when it's viewport is enabled
|
2012-03-24 07:52:14 +00:00
|
|
|
if (cam && !cam->GetViewport())
|
2009-04-08 15:06:20 +00:00
|
|
|
{
|
|
|
|
if (scene->IsClearingZBuffer())
|
|
|
|
m_rasterizer->ClearDepthBuffer();
|
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->SetAuxilaryClientInfo(scene);
|
2009-04-08 15:06:20 +00:00
|
|
|
|
|
|
|
// do the rendering
|
|
|
|
m_dome->RenderDomeFrame(scene,cam, i);
|
2011-09-16 18:23:57 +00:00
|
|
|
//render all the font objects for this scene
|
2013-06-20 03:50:02 +00:00
|
|
|
scene->RenderFonts();
|
2009-04-08 15:06:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
list<class KX_Camera*>* cameras = scene->GetCameras();
|
|
|
|
|
|
|
|
// Draw the scene once for each camera with an enabled viewport
|
|
|
|
list<KX_Camera*>::iterator it = cameras->begin();
|
2012-10-21 07:58:38 +00:00
|
|
|
while (it != cameras->end()) {
|
2012-03-24 07:52:14 +00:00
|
|
|
if ((*it)->GetViewport())
|
2009-04-08 15:06:20 +00:00
|
|
|
{
|
|
|
|
if (scene->IsClearingZBuffer())
|
|
|
|
m_rasterizer->ClearDepthBuffer();
|
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->SetAuxilaryClientInfo(scene);
|
2009-04-08 15:06:20 +00:00
|
|
|
|
|
|
|
// do the rendering
|
|
|
|
m_dome->RenderDomeFrame(scene, (*it),i);
|
2011-09-16 18:23:57 +00:00
|
|
|
//render all the font objects for this scene
|
2013-06-20 03:50:02 +00:00
|
|
|
scene->RenderFonts();
|
2009-04-08 15:06:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
it++;
|
|
|
|
}
|
2010-03-03 06:38:47 +00:00
|
|
|
// Part of PostRenderScene()
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->MotionBlur();
|
2010-03-03 06:38:47 +00:00
|
|
|
scene->Render2DFilters(m_canvas);
|
|
|
|
// no RunDrawingCallBacks
|
|
|
|
// no FlushDebugLines
|
2009-04-08 15:06:20 +00:00
|
|
|
}
|
|
|
|
m_dome->BindImages(i);
|
2012-09-16 04:58:18 +00:00
|
|
|
}
|
2009-04-08 15:06:20 +00:00
|
|
|
|
|
|
|
m_canvas->EndFrame();//XXX do we really need that?
|
|
|
|
|
|
|
|
m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
|
|
|
|
|
|
|
|
if (m_overrideFrameColor) //XXX why do we want
|
|
|
|
{
|
|
|
|
// Do not use the framing bar color set in the Blender scenes
|
|
|
|
m_canvas->ClearColor(
|
|
|
|
m_overrideFrameColorR,
|
|
|
|
m_overrideFrameColorG,
|
|
|
|
m_overrideFrameColorB,
|
|
|
|
1.0
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Use the framing bar color set in the Blender scenes
|
|
|
|
m_canvas->ClearColor(
|
|
|
|
framesettings.BarRed(),
|
|
|
|
framesettings.BarGreen(),
|
|
|
|
framesettings.BarBlue(),
|
|
|
|
1.0
|
|
|
|
);
|
|
|
|
}
|
|
|
|
m_dome->Draw();
|
2010-03-28 10:20:26 +00:00
|
|
|
// Draw Callback for the last scene
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2010-03-28 10:20:26 +00:00
|
|
|
scene->RunDrawingCallbacks(scene->GetPostDrawCB());
|
2012-09-16 04:58:18 +00:00
|
|
|
#endif
|
2009-04-08 15:06:20 +00:00
|
|
|
EndFrame();
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-04 04:35:12 +00:00
|
|
|
* Ketsji Init(), Initializes data-structures and converts data from
|
2002-10-12 11:37:38 +00:00
|
|
|
* Blender into Ketsji native (realtime) format also sets up the
|
|
|
|
* graphics context
|
|
|
|
*/
|
2006-11-30 00:19:27 +00:00
|
|
|
void KX_KetsjiEngine::StartEngine(bool clearIpo)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2006-12-03 01:16:17 +00:00
|
|
|
m_clockTime = m_kxsystem->GetTimeInSeconds();
|
|
|
|
m_frameTime = m_kxsystem->GetTimeInSeconds();
|
|
|
|
m_previousClockTime = m_kxsystem->GetTimeInSeconds();
|
2006-01-12 06:30:01 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
m_firstframe = true;
|
|
|
|
m_bInitialized = true;
|
2009-05-21 18:10:19 +00:00
|
|
|
// there is always one scene enabled at startup
|
2009-08-23 17:33:34 +00:00
|
|
|
Scene* scene = m_scenes[0]->GetBlenderScene();
|
|
|
|
if (scene)
|
2009-05-21 18:10:19 +00:00
|
|
|
{
|
2009-08-23 17:33:34 +00:00
|
|
|
m_ticrate = scene->gm.ticrate ? scene->gm.ticrate : DEFAULT_LOGIC_TIC_RATE;
|
|
|
|
m_maxLogicFrame = scene->gm.maxlogicstep ? scene->gm.maxlogicstep : 5;
|
|
|
|
m_maxPhysicsFrame = scene->gm.maxphystep ? scene->gm.maxlogicstep : 5;
|
2009-05-21 18:10:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ticrate = DEFAULT_LOGIC_TIC_RATE;
|
|
|
|
m_maxLogicFrame = 5;
|
|
|
|
m_maxPhysicsFrame = 5;
|
|
|
|
}
|
2006-05-10 00:05:49 +00:00
|
|
|
|
2010-02-22 12:25:58 +00:00
|
|
|
if (m_animation_record)
|
2006-01-12 06:30:01 +00:00
|
|
|
{
|
2006-11-30 00:19:27 +00:00
|
|
|
m_sceneconverter->ResetPhysicsObjectsAnimationIpo(clearIpo);
|
2006-05-10 00:05:49 +00:00
|
|
|
m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame);
|
2006-01-12 06:30:01 +00:00
|
|
|
}
|
2005-08-22 18:31:19 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
void KX_KetsjiEngine::ClearFrame()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-09-14 00:32:18 +00:00
|
|
|
// clear unless we're drawing overlapping stereo
|
2012-03-24 07:52:14 +00:00
|
|
|
if (m_rasterizer->InterlacedStereo() &&
|
2008-09-14 00:32:18 +00:00
|
|
|
m_rasterizer->GetEye() == RAS_IRasterizer::RAS_STEREO_RIGHTEYE)
|
|
|
|
return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
// clear the viewports with the background color of the first scene
|
|
|
|
bool doclear = false;
|
|
|
|
KX_SceneList::iterator sceneit;
|
|
|
|
RAS_Rect clearvp, area, viewport;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
for (sceneit = m_scenes.begin(); sceneit != m_scenes.end(); sceneit++)
|
|
|
|
{
|
|
|
|
KX_Scene* scene = *sceneit;
|
|
|
|
//const RAS_FrameSettings &framesettings = scene->GetFramingType();
|
|
|
|
list<class KX_Camera*>* cameras = scene->GetCameras();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
list<KX_Camera*>::iterator it;
|
2012-03-24 07:52:14 +00:00
|
|
|
for (it = cameras->begin(); it != cameras->end(); it++)
|
2008-09-14 00:32:18 +00:00
|
|
|
{
|
2008-09-18 01:46:28 +00:00
|
|
|
GetSceneViewport(scene, (*it), area, viewport);
|
2008-09-14 00:32:18 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (!doclear) {
|
2008-09-14 00:32:18 +00:00
|
|
|
clearvp = viewport;
|
|
|
|
doclear = true;
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 07:52:14 +00:00
|
|
|
if (viewport.GetLeft() < clearvp.GetLeft())
|
2008-09-14 00:32:18 +00:00
|
|
|
clearvp.SetLeft(viewport.GetLeft());
|
2012-03-24 07:52:14 +00:00
|
|
|
if (viewport.GetBottom() < clearvp.GetBottom())
|
2008-09-14 00:32:18 +00:00
|
|
|
clearvp.SetBottom(viewport.GetBottom());
|
2012-03-24 07:52:14 +00:00
|
|
|
if (viewport.GetRight() > clearvp.GetRight())
|
2008-09-14 00:32:18 +00:00
|
|
|
clearvp.SetRight(viewport.GetRight());
|
2012-03-24 07:52:14 +00:00
|
|
|
if (viewport.GetTop() > clearvp.GetTop())
|
2008-09-14 00:32:18 +00:00
|
|
|
clearvp.SetTop(viewport.GetTop());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (doclear) {
|
2008-09-14 00:32:18 +00:00
|
|
|
KX_Scene* firstscene = *m_scenes.begin();
|
|
|
|
SetBackGround(firstscene->GetWorldInfo());
|
|
|
|
|
|
|
|
m_canvas->SetViewPort(clearvp.GetLeft(), clearvp.GetBottom(),
|
2012-09-16 04:58:18 +00:00
|
|
|
clearvp.GetRight(), clearvp.GetTop());
|
2008-09-14 00:32:18 +00:00
|
|
|
m_rasterizer->ClearColorBuffer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KX_KetsjiEngine::BeginFrame()
|
|
|
|
{
|
|
|
|
// set the area used for rendering (stereo can assign only a subset)
|
|
|
|
m_rasterizer->SetRenderArea();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (m_canvas->BeginDraw())
|
|
|
|
{
|
2008-09-14 00:32:18 +00:00
|
|
|
ClearFrame();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-03-25 03:11:11 +00:00
|
|
|
m_rasterizer->BeginFrame(m_kxsystem->GetTimeInSeconds());
|
2008-09-14 00:32:18 +00:00
|
|
|
|
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
return false;
|
2012-09-16 04:58:18 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::EndFrame()
|
|
|
|
{
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->MotionBlur();
|
2012-07-23 01:00:56 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// Show profiling info
|
|
|
|
m_logger->StartLog(tc_overhead, m_kxsystem->GetTimeInSeconds(), true);
|
2013-07-09 20:06:36 +00:00
|
|
|
if (m_show_framerate || m_show_profile || (m_show_debug_properties))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
RenderDebugProperties();
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2013-06-17 06:40:39 +00:00
|
|
|
double tottime = m_logger->GetAverage(), time;
|
|
|
|
if (tottime < 1e-6)
|
|
|
|
tottime = 1e-6;
|
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
for (int i = tc_first; i < tc_numCategories; ++i) {
|
|
|
|
time = m_logger->GetAverage((KX_TimeCategory)i);
|
|
|
|
PyObject *val = PyTuple_New(2);
|
|
|
|
PyTuple_SetItem(val, 0, PyFloat_FromDouble(time*1000.f));
|
|
|
|
PyTuple_SetItem(val, 1, PyFloat_FromDouble(time/tottime * 100.f));
|
|
|
|
|
|
|
|
PyDict_SetItemString(m_pyprofiledict, m_profileLabels[i], val);
|
|
|
|
Py_DECREF(val);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_average_framerate = 1.0/tottime;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// Go to next profiling measurement, time spend after this call is shown in the next frame.
|
|
|
|
m_logger->NextMeasurement(m_kxsystem->GetTimeInSeconds());
|
|
|
|
|
|
|
|
m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
m_rasterizer->EndFrame();
|
|
|
|
// swap backbuffer (drawing into this buffer) <-> front/visible buffer
|
2013-08-13 03:09:58 +00:00
|
|
|
m_logger->StartLog(tc_latency, m_kxsystem->GetTimeInSeconds(), true);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_rasterizer->SwapBuffers();
|
2013-08-13 03:09:58 +00:00
|
|
|
m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
m_canvas->EndDraw();
|
|
|
|
}
|
|
|
|
|
2006-12-02 22:25:47 +00:00
|
|
|
//#include "PIL_time.h"
|
|
|
|
//#include "LinearMath/btQuickprof.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-02 22:25:47 +00:00
|
|
|
|
|
|
|
bool KX_KetsjiEngine::NextFrame()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-05-01 16:35:06 +00:00
|
|
|
double timestep = 1.0/m_ticrate;
|
|
|
|
double framestep = timestep;
|
2012-11-22 05:20:51 +00:00
|
|
|
// static hidden::Clock sClock;
|
2006-12-02 22:25:47 +00:00
|
|
|
|
2012-11-22 05:20:51 +00:00
|
|
|
m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(),true);
|
2006-12-02 22:25:47 +00:00
|
|
|
|
2012-11-22 05:20:51 +00:00
|
|
|
//float dt = sClock.getTimeMicroseconds() * 0.000001f;
|
|
|
|
//sClock.reset();
|
2006-12-02 22:25:47 +00:00
|
|
|
|
2012-11-22 05:20:51 +00:00
|
|
|
if (m_bFixedTime) {
|
|
|
|
m_clockTime += timestep;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// m_clockTime += dt;
|
|
|
|
m_clockTime = m_kxsystem->GetTimeInSeconds();
|
|
|
|
}
|
2005-07-16 21:47:54 +00:00
|
|
|
|
2006-01-12 06:30:01 +00:00
|
|
|
double deltatime = m_clockTime - m_frameTime;
|
2006-02-13 06:28:35 +00:00
|
|
|
if (deltatime<0.f)
|
|
|
|
{
|
2012-11-24 08:10:56 +00:00
|
|
|
// We got here too quickly, which means there is nothing todo, just return and don't render.
|
|
|
|
// Not sure if this is the best fix, but it seems to stop the jumping framerate issue (#33088)
|
|
|
|
return false;
|
2006-02-13 06:28:35 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-02 22:25:47 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
// Compute the number of logic frames to do each update (fixed tic bricks)
|
2009-04-07 22:14:06 +00:00
|
|
|
int frames =int(deltatime*m_ticrate+1e-6);
|
2006-12-02 22:25:47 +00:00
|
|
|
// if (frames>1)
|
|
|
|
// printf("****************************************");
|
|
|
|
// printf("dt = %f, deltatime = %f, frames = %d\n",dt, deltatime,frames);
|
2006-01-12 06:30:01 +00:00
|
|
|
|
|
|
|
// if (!frames)
|
2006-12-02 22:25:47 +00:00
|
|
|
// PIL_sleep_ms(1);
|
2004-10-16 11:41:50 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_SceneList::iterator sceneit;
|
2004-10-16 11:41:50 +00:00
|
|
|
|
2009-05-21 18:10:19 +00:00
|
|
|
if (frames>m_maxPhysicsFrame)
|
2006-02-13 06:28:35 +00:00
|
|
|
{
|
2006-12-02 22:25:47 +00:00
|
|
|
|
|
|
|
// printf("framedOut: %d\n",frames);
|
2009-05-21 18:10:19 +00:00
|
|
|
m_frameTime+=(frames-m_maxPhysicsFrame)*timestep;
|
|
|
|
frames = m_maxPhysicsFrame;
|
2006-02-13 06:28:35 +00:00
|
|
|
}
|
2006-12-02 22:25:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool doRender = frames>0;
|
|
|
|
|
2009-05-01 16:35:06 +00:00
|
|
|
if (frames > m_maxLogicFrame)
|
|
|
|
{
|
|
|
|
framestep = (frames*timestep)/m_maxLogicFrame;
|
|
|
|
frames = m_maxLogicFrame;
|
|
|
|
}
|
2011-08-11 07:19:37 +00:00
|
|
|
|
2004-11-22 10:19:19 +00:00
|
|
|
while (frames)
|
2004-10-16 11:41:50 +00:00
|
|
|
{
|
2006-12-02 22:25:47 +00:00
|
|
|
|
2005-07-16 21:47:54 +00:00
|
|
|
|
2009-05-01 16:35:06 +00:00
|
|
|
m_frameTime += framestep;
|
2006-01-12 06:30:01 +00:00
|
|
|
|
2012-12-22 05:38:32 +00:00
|
|
|
m_sceneconverter->MergeAsyncLoads();
|
|
|
|
|
2004-11-06 04:58:10 +00:00
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit)
|
2004-10-16 11:41:50 +00:00
|
|
|
// for each scene, call the proceed functions
|
|
|
|
{
|
|
|
|
KX_Scene* scene = *sceneit;
|
|
|
|
|
|
|
|
/* Suspension holds the physics and logic processing for an
|
2012-03-09 18:28:30 +00:00
|
|
|
* entire scene. Objects can be suspended individually, and
|
2012-07-04 15:04:38 +00:00
|
|
|
* the settings for that precede the logic and physics
|
2012-03-09 18:28:30 +00:00
|
|
|
* update. */
|
2002-10-12 11:37:38 +00:00
|
|
|
m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
|
2006-12-16 05:50:38 +00:00
|
|
|
|
|
|
|
m_sceneconverter->resetNoneDynamicObjectToIpo();//this is for none dynamic objects with ipo
|
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
scene->UpdateObjectActivity();
|
|
|
|
|
|
|
|
if (!scene->IsSuspended())
|
|
|
|
{
|
2005-12-18 19:10:26 +00:00
|
|
|
// if the scene was suspended recalcutlate the delta tu "curtime"
|
|
|
|
m_suspendedtime = scene->getSuspendedTime();
|
|
|
|
if (scene->getSuspendedTime()!=0.0)
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->setSuspendedDelta(scene->getSuspendedDelta()+m_clockTime-scene->getSuspendedTime());
|
2005-12-18 19:10:26 +00:00
|
|
|
m_suspendeddelta = scene->getSuspendedDelta();
|
|
|
|
|
2005-12-31 21:59:56 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
m_logger->StartLog(tc_network, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_NETWORK);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->GetNetworkScene()->proceed(m_frameTime);
|
2004-10-16 11:41:50 +00:00
|
|
|
|
2009-04-07 22:14:06 +00:00
|
|
|
//m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
//SG_SetActiveStage(SG_STAGE_NETWORK_UPDATE);
|
|
|
|
//scene->UpdateParents(m_frameTime);
|
2005-12-31 21:59:56 +00:00
|
|
|
|
|
|
|
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_PHYSICS1);
|
2004-10-16 11:41:50 +00:00
|
|
|
// set Python hooks for each scene
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2004-10-16 11:41:50 +00:00
|
|
|
PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
2008-10-31 21:06:48 +00:00
|
|
|
KX_SetActiveScene(scene);
|
2004-10-16 11:41:50 +00:00
|
|
|
|
BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code.
This is a squashed commit of the following:
BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks.
BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController.
BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController.
BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp.
BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes.
BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject.
BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController.
BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController.
BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now.
BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController.
BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController.
BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate.
BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController.
BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController.
BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity().
BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface.
BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController.
BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController.
BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation).
BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller.
BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1().
2013-11-04 19:22:47 +00:00
|
|
|
scene->GetPhysicsEnvironment()->EndFrame();
|
2004-11-22 10:19:19 +00:00
|
|
|
|
2004-11-06 12:31:56 +00:00
|
|
|
// Update scenegraph after physics step. This maps physics calculations
|
2012-09-16 04:58:18 +00:00
|
|
|
// into node positions.
|
2009-04-07 22:14:06 +00:00
|
|
|
//m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
//SG_SetActiveStage(SG_STAGE_PHYSICS1_UPDATE);
|
|
|
|
//scene->UpdateParents(m_frameTime);
|
2004-11-06 12:31:56 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
// Process sensors, and controllers
|
|
|
|
m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_CONTROLLER);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->LogicBeginFrame(m_frameTime);
|
2004-10-16 11:41:50 +00:00
|
|
|
|
|
|
|
// Scenegraph needs to be updated again, because Logic Controllers
|
|
|
|
// can affect the local matrices.
|
|
|
|
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_CONTROLLER_UPDATE);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->UpdateParents(m_frameTime);
|
2004-10-16 11:41:50 +00:00
|
|
|
|
|
|
|
// Process actuators
|
|
|
|
|
|
|
|
// Do some cleanup work for this logic frame
|
|
|
|
m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_ACTUATOR);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->LogicUpdateFrame(m_frameTime, true);
|
2006-12-02 22:25:47 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
scene->LogicEndFrame();
|
|
|
|
|
|
|
|
// Actuators can affect the scenegraph
|
|
|
|
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_ACTUATOR_UPDATE);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->UpdateParents(m_frameTime);
|
2011-08-12 20:53:29 +00:00
|
|
|
|
|
|
|
if (!GetRestrictAnimationFPS())
|
|
|
|
{
|
|
|
|
m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
|
|
|
|
scene->UpdateAnimations(m_frameTime);
|
|
|
|
}
|
|
|
|
|
2005-12-31 21:59:56 +00:00
|
|
|
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_PHYSICS2);
|
BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code.
This is a squashed commit of the following:
BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks.
BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController.
BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController.
BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp.
BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes.
BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject.
BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController.
BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController.
BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now.
BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController.
BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController.
BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate.
BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController.
BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController.
BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity().
BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface.
BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController.
BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController.
BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation).
BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller.
BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1().
2013-11-04 19:22:47 +00:00
|
|
|
scene->GetPhysicsEnvironment()->BeginFrame();
|
2004-11-22 10:19:19 +00:00
|
|
|
|
|
|
|
// Perform physics calculations on the scene. This can involve
|
|
|
|
// many iterations of the physics solver.
|
BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code.
This is a squashed commit of the following:
BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks.
BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController.
BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController.
BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp.
BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes.
BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject.
BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController.
BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController.
BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now.
BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController.
BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController.
BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate.
BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController.
BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController.
BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity().
BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface.
BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController.
BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController.
BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation).
BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller.
BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1().
2013-11-04 19:22:47 +00:00
|
|
|
scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime);
|
2005-08-22 18:31:19 +00:00
|
|
|
|
2006-01-12 06:30:01 +00:00
|
|
|
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_PHYSICS2_UPDATE);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->UpdateParents(m_frameTime);
|
|
|
|
|
|
|
|
|
2010-02-22 12:25:58 +00:00
|
|
|
if (m_animation_record)
|
2012-09-16 04:58:18 +00:00
|
|
|
{
|
2006-05-10 00:05:49 +00:00
|
|
|
m_sceneconverter->WritePhysicsObjectToAnimationIpo(++m_currentFrame);
|
2005-08-23 13:16:02 +00:00
|
|
|
}
|
2005-08-22 18:31:19 +00:00
|
|
|
|
2005-12-18 19:10:26 +00:00
|
|
|
scene->setSuspendedTime(0.0);
|
2004-10-16 11:41:50 +00:00
|
|
|
} // suspended
|
2005-12-18 19:10:26 +00:00
|
|
|
else
|
2012-03-24 07:52:14 +00:00
|
|
|
if (scene->getSuspendedTime()==0.0)
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->setSuspendedTime(m_clockTime);
|
2006-12-02 22:25:47 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
// update system devices
|
|
|
|
m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
if (m_keyboarddevice)
|
|
|
|
m_keyboarddevice->NextFrame();
|
|
|
|
|
|
|
|
if (m_mousedevice)
|
|
|
|
m_mousedevice->NextFrame();
|
|
|
|
|
|
|
|
if (m_networkdevice)
|
|
|
|
m_networkdevice->NextFrame();
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
// scene management
|
|
|
|
ProcessScheduledScenes();
|
2004-11-22 10:19:19 +00:00
|
|
|
|
|
|
|
frames--;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2006-12-02 22:25:47 +00:00
|
|
|
bool bUseAsyncLogicBricks= false;//true;
|
2004-11-22 10:19:19 +00:00
|
|
|
|
2006-01-18 06:04:11 +00:00
|
|
|
if (bUseAsyncLogicBricks)
|
2012-09-16 04:58:18 +00:00
|
|
|
{
|
2006-01-12 06:30:01 +00:00
|
|
|
// Logic update sub frame: this will let some logic bricks run at the
|
|
|
|
// full frame rate.
|
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit)
|
|
|
|
// for each scene, call the proceed functions
|
2004-11-22 10:19:19 +00:00
|
|
|
{
|
2006-01-12 06:30:01 +00:00
|
|
|
KX_Scene* scene = *sceneit;
|
|
|
|
|
|
|
|
if (!scene->IsSuspended())
|
|
|
|
{
|
|
|
|
// if the scene was suspended recalcutlate the delta tu "curtime"
|
|
|
|
m_suspendedtime = scene->getSuspendedTime();
|
|
|
|
if (scene->getSuspendedTime()!=0.0)
|
|
|
|
scene->setSuspendedDelta(scene->getSuspendedDelta()+m_clockTime-scene->getSuspendedTime());
|
|
|
|
m_suspendeddelta = scene->getSuspendedDelta();
|
|
|
|
|
|
|
|
// set Python hooks for each scene
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2006-01-12 06:30:01 +00:00
|
|
|
PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
2008-10-31 21:06:48 +00:00
|
|
|
KX_SetActiveScene(scene);
|
2006-01-12 06:30:01 +00:00
|
|
|
|
|
|
|
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_PHYSICS1);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->UpdateParents(m_clockTime);
|
|
|
|
|
|
|
|
// Perform physics calculations on the scene. This can involve
|
|
|
|
// many iterations of the physics solver.
|
|
|
|
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
|
BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code.
This is a squashed commit of the following:
BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks.
BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController.
BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController.
BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp.
BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes.
BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject.
BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController.
BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController.
BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now.
BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController.
BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController.
BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate.
BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController.
BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController.
BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity().
BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface.
BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController.
BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController.
BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation).
BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller.
BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1().
2013-11-04 19:22:47 +00:00
|
|
|
scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_clockTime,timestep,timestep);
|
2006-01-12 06:30:01 +00:00
|
|
|
// Update scenegraph after physics step. This maps physics calculations
|
2012-09-16 04:58:18 +00:00
|
|
|
// into node positions.
|
2006-01-12 06:30:01 +00:00
|
|
|
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_PHYSICS2);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->UpdateParents(m_clockTime);
|
|
|
|
|
|
|
|
// Do some cleanup work for this logic frame
|
|
|
|
m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
scene->LogicUpdateFrame(m_clockTime, false);
|
2004-11-22 10:19:19 +00:00
|
|
|
|
2006-01-12 06:30:01 +00:00
|
|
|
// Actuators can affect the scenegraph
|
|
|
|
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_ACTUATOR);
|
2006-01-12 06:30:01 +00:00
|
|
|
scene->UpdateParents(m_clockTime);
|
2011-09-25 12:31:21 +00:00
|
|
|
|
|
|
|
scene->setSuspendedTime(0.0);
|
2006-01-12 06:30:01 +00:00
|
|
|
} // suspended
|
2011-09-25 12:31:21 +00:00
|
|
|
else
|
2012-03-24 07:52:14 +00:00
|
|
|
if (scene->getSuspendedTime()==0.0)
|
2011-09-25 12:31:21 +00:00
|
|
|
scene->setSuspendedTime(m_clockTime);
|
2004-11-22 10:19:19 +00:00
|
|
|
|
2006-01-12 06:30:01 +00:00
|
|
|
m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
}
|
2004-11-22 10:19:19 +00:00
|
|
|
}
|
2006-01-12 06:30:01 +00:00
|
|
|
|
2011-08-11 07:19:37 +00:00
|
|
|
|
|
|
|
// Handle the animations independently of the logic time step
|
2011-08-12 20:53:29 +00:00
|
|
|
if (GetRestrictAnimationFPS())
|
2011-08-11 07:19:37 +00:00
|
|
|
{
|
2012-07-29 23:53:21 +00:00
|
|
|
double clocktime = m_kxsystem->GetTimeInSeconds();
|
|
|
|
m_logger->StartLog(tc_animations, clocktime, true);
|
2011-08-12 20:53:29 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
|
2006-01-12 06:30:01 +00:00
|
|
|
|
2011-08-12 20:53:29 +00:00
|
|
|
double anim_timestep = 1.0/KX_GetActiveScene()->GetAnimationFPS();
|
2012-07-29 23:53:21 +00:00
|
|
|
if (clocktime - m_previousAnimTime > anim_timestep)
|
2011-08-11 07:19:37 +00:00
|
|
|
{
|
2011-08-12 20:53:29 +00:00
|
|
|
// Sanity/debug print to make sure we're actually going at the fps we want (should be close to anim_timestep)
|
|
|
|
// printf("Anim fps: %f\n", 1.0/(m_clockTime - m_previousAnimTime));
|
2012-07-29 23:53:21 +00:00
|
|
|
m_previousAnimTime = clocktime;
|
2011-08-12 20:53:29 +00:00
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit)
|
|
|
|
{
|
2012-07-29 23:53:21 +00:00
|
|
|
(*sceneit)->UpdateAnimations(clocktime);
|
2011-08-12 20:53:29 +00:00
|
|
|
}
|
2011-08-11 07:19:37 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-22 10:19:19 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// Start logging time spend outside main loop
|
|
|
|
m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true);
|
2006-12-02 22:25:47 +00:00
|
|
|
|
|
|
|
return doRender;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::Render()
|
|
|
|
{
|
2012-03-28 05:03:24 +00:00
|
|
|
if (m_usedome) {
|
2009-04-08 15:06:20 +00:00
|
|
|
RenderDome();
|
|
|
|
return;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_Scene* firstscene = *m_scenes.begin();
|
|
|
|
const RAS_FrameSettings &framesettings = firstscene->GetFramingType();
|
|
|
|
|
|
|
|
m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
|
2009-04-07 22:14:06 +00:00
|
|
|
SG_SetActiveStage(SG_STAGE_RENDER);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// hiding mouse cursor each frame
|
|
|
|
// (came back when going out of focus and then back in again)
|
|
|
|
if (m_hideCursor)
|
|
|
|
m_canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
|
|
|
|
|
|
|
|
// clear the entire game screen with the border color
|
|
|
|
// only once per frame
|
|
|
|
m_canvas->BeginDraw();
|
2014-03-25 03:11:11 +00:00
|
|
|
if (m_rasterizer->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) {
|
2002-10-12 11:37:38 +00:00
|
|
|
m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
|
|
|
|
if (m_overrideFrameColor)
|
|
|
|
{
|
|
|
|
// Do not use the framing bar color set in the Blender scenes
|
|
|
|
m_canvas->ClearColor(
|
|
|
|
m_overrideFrameColorR,
|
|
|
|
m_overrideFrameColorG,
|
|
|
|
m_overrideFrameColorB,
|
|
|
|
1.0
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Use the framing bar color set in the Blender scenes
|
|
|
|
m_canvas->ClearColor(
|
|
|
|
framesettings.BarRed(),
|
|
|
|
framesettings.BarGreen(),
|
|
|
|
framesettings.BarBlue(),
|
|
|
|
1.0
|
|
|
|
);
|
|
|
|
}
|
|
|
|
// clear the -whole- viewport
|
2008-09-14 00:32:18 +00:00
|
|
|
m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_LEFTEYE);
|
|
|
|
|
|
|
|
// BeginFrame() sets the actual drawing area. You can use a part of the window
|
|
|
|
if (!BeginFrame())
|
|
|
|
return;
|
|
|
|
|
|
|
|
KX_SceneList::iterator sceneit;
|
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
|
|
|
|
// for each scene, call the proceed functions
|
|
|
|
{
|
|
|
|
KX_Scene* scene = *sceneit;
|
2006-01-06 03:46:54 +00:00
|
|
|
KX_Camera* cam = scene->GetActiveCamera();
|
2002-10-12 11:37:38 +00:00
|
|
|
// pass the scene's worldsettings to the rasterizer
|
|
|
|
SetWorldSettings(scene->GetWorldInfo());
|
|
|
|
|
BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive
performance improvement in the culling and in the rasterizer when
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms) 2.48 1st round 3rd round
All objects static, 323.0 86.0 7.2
all visible, 1000 in
the view frustrum
All objects static, 219.0 49.7 N/A(*)
all invisible.
All objects moving, 323.0 105.6 34.7
all visible, 1000 in
the view frustrum
Scene destruction 40min 40min 4s
(*) : this time is not representative because the frame rate was at 60fps.
In that case, the GPU holds down the GE by frame sync. By design, the
overhead of the rasterizer is 0 when the the objects are invisible.
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
2009-05-07 09:13:01 +00:00
|
|
|
// this is now done incrementatlly in KX_Scene::CalculateVisibleMeshes
|
|
|
|
//scene->UpdateMeshTransformations();
|
2009-04-13 20:08:33 +00:00
|
|
|
|
2008-07-10 12:47:20 +00:00
|
|
|
// shadow buffers
|
|
|
|
RenderShadowBuffers(scene);
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
// Avoid drawing the scene with the active camera twice when it's viewport is enabled
|
2012-03-24 07:52:14 +00:00
|
|
|
if (cam && !cam->GetViewport())
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
if (scene->IsClearingZBuffer())
|
|
|
|
m_rasterizer->ClearDepthBuffer();
|
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->SetAuxilaryClientInfo(scene);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// do the rendering
|
|
|
|
RenderFrame(scene, cam);
|
|
|
|
}
|
|
|
|
|
2008-02-15 23:12:03 +00:00
|
|
|
list<class KX_Camera*>* cameras = scene->GetCameras();
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// Draw the scene once for each camera with an enabled viewport
|
2008-02-15 23:12:03 +00:00
|
|
|
list<KX_Camera*>::iterator it = cameras->begin();
|
2012-10-21 07:58:38 +00:00
|
|
|
while (it != cameras->end()) {
|
2012-03-24 07:52:14 +00:00
|
|
|
if ((*it)->GetViewport())
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
if (scene->IsClearingZBuffer())
|
|
|
|
m_rasterizer->ClearDepthBuffer();
|
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->SetAuxilaryClientInfo(scene);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// do the rendering
|
|
|
|
RenderFrame(scene, (*it));
|
|
|
|
}
|
|
|
|
|
|
|
|
it++;
|
|
|
|
}
|
2010-03-03 06:38:47 +00:00
|
|
|
PostRenderScene(scene);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// only one place that checks for stereo
|
2012-03-24 07:52:14 +00:00
|
|
|
if (m_rasterizer->Stereo())
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_RIGHTEYE);
|
|
|
|
|
|
|
|
if (!BeginFrame())
|
|
|
|
return;
|
|
|
|
|
2009-02-25 03:26:02 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
|
|
|
|
// for each scene, call the proceed functions
|
|
|
|
{
|
|
|
|
KX_Scene* scene = *sceneit;
|
2006-01-06 03:46:54 +00:00
|
|
|
KX_Camera* cam = scene->GetActiveCamera();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// pass the scene's worldsettings to the rasterizer
|
|
|
|
SetWorldSettings(scene->GetWorldInfo());
|
|
|
|
|
|
|
|
if (scene->IsClearingZBuffer())
|
|
|
|
m_rasterizer->ClearDepthBuffer();
|
|
|
|
|
|
|
|
//pass the scene, for picking and raycasting (shadows)
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->SetAuxilaryClientInfo(scene);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// do the rendering
|
2006-01-06 03:46:54 +00:00
|
|
|
//RenderFrame(scene);
|
|
|
|
RenderFrame(scene, cam);
|
2009-01-24 21:19:35 +00:00
|
|
|
|
2012-09-16 04:58:18 +00:00
|
|
|
list<class KX_Camera*>* cameras = scene->GetCameras();
|
2009-01-24 21:19:35 +00:00
|
|
|
|
|
|
|
// Draw the scene once for each camera with an enabled viewport
|
|
|
|
list<KX_Camera*>::iterator it = cameras->begin();
|
2012-10-21 07:58:38 +00:00
|
|
|
while (it != cameras->end()) {
|
2012-03-24 07:52:14 +00:00
|
|
|
if ((*it)->GetViewport())
|
2009-01-24 21:19:35 +00:00
|
|
|
{
|
|
|
|
if (scene->IsClearingZBuffer())
|
|
|
|
m_rasterizer->ClearDepthBuffer();
|
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->SetAuxilaryClientInfo(scene);
|
2009-01-24 21:19:35 +00:00
|
|
|
|
|
|
|
// do the rendering
|
|
|
|
RenderFrame(scene, (*it));
|
|
|
|
}
|
|
|
|
|
|
|
|
it++;
|
|
|
|
}
|
2010-03-03 06:38:47 +00:00
|
|
|
PostRenderScene(scene);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
} // if (m_rasterizer->Stereo())
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
EndFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::RequestExit(int exitrequestmode)
|
|
|
|
{
|
|
|
|
m_exitcode = exitrequestmode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetNameNextGame(const STR_String& nextgame)
|
|
|
|
{
|
|
|
|
m_exitstring = nextgame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int KX_KetsjiEngine::GetExitCode()
|
|
|
|
{
|
|
|
|
// if a gameactuator has set an exitcode or if there are no scenes left
|
|
|
|
if (!m_exitcode)
|
|
|
|
{
|
|
|
|
if (m_scenes.begin()==m_scenes.end())
|
|
|
|
m_exitcode = KX_EXIT_REQUEST_NO_SCENES_LEFT;
|
|
|
|
}
|
2010-11-30 21:51:03 +00:00
|
|
|
|
|
|
|
// check if the window has been closed.
|
2012-03-24 07:52:14 +00:00
|
|
|
if (!m_exitcode)
|
2010-11-30 21:51:03 +00:00
|
|
|
{
|
2012-03-28 05:03:24 +00:00
|
|
|
//if (!m_canvas->Check()) {
|
2010-11-30 21:51:03 +00:00
|
|
|
// m_exitcode = KX_EXIT_REQUEST_OUTSIDE;
|
|
|
|
//}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
return m_exitcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const STR_String& KX_KetsjiEngine::GetExitString()
|
|
|
|
{
|
|
|
|
return m_exitstring;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetBackGround(KX_WorldInfo* wi)
|
|
|
|
{
|
|
|
|
if (wi->hasWorld())
|
|
|
|
{
|
2014-03-25 03:11:11 +00:00
|
|
|
if (m_rasterizer->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
|
2012-09-16 04:58:18 +00:00
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
m_rasterizer->SetBackColor(
|
|
|
|
wi->getBackColorRed(),
|
|
|
|
wi->getBackColorGreen(),
|
|
|
|
wi->getBackColorBlue(),
|
|
|
|
0.0
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetWorldSettings(KX_WorldInfo* wi)
|
|
|
|
{
|
|
|
|
if (wi->hasWorld())
|
|
|
|
{
|
2006-01-06 03:46:54 +00:00
|
|
|
// ...
|
|
|
|
m_rasterizer->SetAmbientColor(
|
|
|
|
wi->getAmbientColorRed(),
|
|
|
|
wi->getAmbientColorGreen(),
|
|
|
|
wi->getAmbientColorBlue()
|
|
|
|
);
|
|
|
|
|
2014-03-25 03:11:11 +00:00
|
|
|
if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
|
2012-09-16 04:58:18 +00:00
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
if (wi->hasMist())
|
|
|
|
{
|
|
|
|
m_rasterizer->SetFog(
|
|
|
|
wi->getMistStart(),
|
|
|
|
wi->getMistDistance(),
|
|
|
|
wi->getMistColorRed(),
|
|
|
|
wi->getMistColorGreen(),
|
|
|
|
wi->getMistColorBlue()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::EnableCameraOverride(const STR_String& forscene)
|
|
|
|
{
|
|
|
|
m_overrideCam = true;
|
|
|
|
m_overrideSceneName = forscene;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetCameraZoom(float camzoom)
|
|
|
|
{
|
|
|
|
m_cameraZoom = camzoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetCameraOverrideUseOrtho(bool useOrtho)
|
|
|
|
{
|
|
|
|
m_overrideCamUseOrtho = useOrtho;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetCameraOverrideProjectionMatrix(const MT_CmMatrix4x4& mat)
|
|
|
|
{
|
|
|
|
m_overrideCamProjMat = mat;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat)
|
|
|
|
{
|
|
|
|
m_overrideCamViewMat = mat;
|
|
|
|
}
|
|
|
|
|
2012-04-29 00:44:49 +00:00
|
|
|
void KX_KetsjiEngine::SetCameraOverrideClipping(float nearfrust, float farfrust)
|
2008-09-15 00:11:30 +00:00
|
|
|
{
|
2012-04-29 00:44:49 +00:00
|
|
|
m_overrideCamNear = nearfrust;
|
|
|
|
m_overrideCamFar = farfrust;
|
2008-09-15 00:11:30 +00:00
|
|
|
}
|
|
|
|
|
2009-06-09 22:56:43 +00:00
|
|
|
void KX_KetsjiEngine::SetCameraOverrideLens(float lens)
|
|
|
|
{
|
|
|
|
m_overrideCamLens = lens;
|
|
|
|
}
|
|
|
|
|
2008-09-18 01:46:28 +00:00
|
|
|
void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
// In this function we make sure the rasterizer settings are upto
|
|
|
|
// date. We compute the viewport so that logic
|
|
|
|
// using this information is upto date.
|
|
|
|
|
|
|
|
// Note we postpone computation of the projection matrix
|
|
|
|
// so that we are using the latest camera position.
|
2008-09-14 00:32:18 +00:00
|
|
|
if (cam->GetViewport()) {
|
|
|
|
RAS_Rect userviewport;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
userviewport.SetLeft(cam->GetViewportLeft());
|
|
|
|
userviewport.SetBottom(cam->GetViewportBottom());
|
|
|
|
userviewport.SetRight(cam->GetViewportRight());
|
|
|
|
userviewport.SetTop(cam->GetViewportTop());
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
// Don't do bars on user specified viewport
|
|
|
|
RAS_FrameSettings settings = scene->GetFramingType();
|
2012-03-24 07:52:14 +00:00
|
|
|
if (settings.FrameType() == RAS_FrameSettings::e_frame_bars)
|
2008-09-14 00:32:18 +00:00
|
|
|
settings.SetFrameType(RAS_FrameSettings::e_frame_extend);
|
2008-03-21 22:44:12 +00:00
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
RAS_FramingManager::ComputeViewport(
|
|
|
|
scene->GetFramingType(),
|
|
|
|
userviewport,
|
|
|
|
viewport
|
|
|
|
);
|
|
|
|
|
|
|
|
area = userviewport;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-04-26 12:23:30 +00:00
|
|
|
else if ( !m_overrideCam || (scene->GetName() != m_overrideSceneName) || m_overrideCamUseOrtho ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
RAS_FramingManager::ComputeViewport(
|
|
|
|
scene->GetFramingType(),
|
|
|
|
m_canvas->GetDisplayArea(),
|
|
|
|
viewport
|
|
|
|
);
|
2008-09-14 00:32:18 +00:00
|
|
|
|
|
|
|
area = m_canvas->GetDisplayArea();
|
2002-10-12 11:37:38 +00:00
|
|
|
} else {
|
|
|
|
viewport.SetLeft(0);
|
|
|
|
viewport.SetBottom(0);
|
|
|
|
viewport.SetRight(int(m_canvas->GetWidth()));
|
|
|
|
viewport.SetTop(int(m_canvas->GetHeight()));
|
|
|
|
|
2008-09-14 00:32:18 +00:00
|
|
|
area = m_canvas->GetDisplayArea();
|
|
|
|
}
|
2008-07-10 12:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
|
|
|
|
{
|
BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive
performance improvement in the culling and in the rasterizer when
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms) 2.48 1st round 3rd round
All objects static, 323.0 86.0 7.2
all visible, 1000 in
the view frustrum
All objects static, 219.0 49.7 N/A(*)
all invisible.
All objects moving, 323.0 105.6 34.7
all visible, 1000 in
the view frustrum
Scene destruction 40min 40min 4s
(*) : this time is not representative because the frame rate was at 60fps.
In that case, the GPU holds down the GE by frame sync. By design, the
overhead of the rasterizer is 0 when the the objects are invisible.
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
2009-05-07 09:13:01 +00:00
|
|
|
CListValue *lightlist = scene->GetLightList();
|
2008-07-10 12:47:20 +00:00
|
|
|
int i, drawmode;
|
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->SetAuxilaryClientInfo(scene);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
for (i=0; i<lightlist->GetCount(); i++) {
|
BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive
performance improvement in the culling and in the rasterizer when
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms) 2.48 1st round 3rd round
All objects static, 323.0 86.0 7.2
all visible, 1000 in
the view frustrum
All objects static, 219.0 49.7 N/A(*)
all invisible.
All objects moving, 323.0 105.6 34.7
all visible, 1000 in
the view frustrum
Scene destruction 40min 40min 4s
(*) : this time is not representative because the frame rate was at 60fps.
In that case, the GPU holds down the GE by frame sync. By design, the
overhead of the rasterizer is 0 when the the objects are invisible.
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
2009-05-07 09:13:01 +00:00
|
|
|
KX_GameObject *gameobj = (KX_GameObject*)lightlist->GetValue(i);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
KX_LightObject *light = (KX_LightObject*)gameobj;
|
2014-03-28 05:32:06 +00:00
|
|
|
RAS_ILightObject *raslight = light->GetLightData();
|
2008-07-10 12:47:20 +00:00
|
|
|
|
2014-03-28 05:32:06 +00:00
|
|
|
raslight->Update();
|
2008-07-10 12:47:20 +00:00
|
|
|
|
2014-03-28 05:32:06 +00:00
|
|
|
if (m_rasterizer->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED && raslight->HasShadowBuffer()) {
|
2008-07-10 12:47:20 +00:00
|
|
|
/* make temporary camera */
|
|
|
|
RAS_CameraData camdata = RAS_CameraData();
|
2009-05-23 14:46:43 +00:00
|
|
|
KX_Camera *cam = new KX_Camera(scene, scene->m_callbacks, camdata, true, true);
|
2008-07-10 12:47:20 +00:00
|
|
|
cam->SetName("__shadow__cam__");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-07-10 12:47:20 +00:00
|
|
|
MT_Transform camtrans;
|
|
|
|
|
|
|
|
/* switch drawmode for speed */
|
|
|
|
drawmode = m_rasterizer->GetDrawingMode();
|
|
|
|
m_rasterizer->SetDrawingMode(RAS_IRasterizer::KX_SHADOW);
|
|
|
|
|
|
|
|
/* binds framebuffer object, sets up camera .. */
|
2014-03-28 05:32:06 +00:00
|
|
|
raslight->BindShadowBuffer(m_canvas, cam, camtrans);
|
2008-07-10 12:47:20 +00:00
|
|
|
|
|
|
|
/* update scene */
|
2014-03-28 05:32:06 +00:00
|
|
|
scene->CalculateVisibleMeshes(m_rasterizer, cam, raslight->GetShadowLayer());
|
2008-07-10 12:47:20 +00:00
|
|
|
|
|
|
|
/* render */
|
|
|
|
m_rasterizer->ClearDepthBuffer();
|
2013-09-05 22:05:52 +00:00
|
|
|
m_rasterizer->ClearColorBuffer();
|
2013-11-04 19:21:07 +00:00
|
|
|
scene->RenderBuckets(camtrans, m_rasterizer);
|
2008-07-10 12:47:20 +00:00
|
|
|
|
|
|
|
/* unbind framebuffer object, restore drawmode, free camera */
|
2014-03-28 05:32:06 +00:00
|
|
|
raslight->UnbindShadowBuffer();
|
2008-07-10 12:47:20 +00:00
|
|
|
m_rasterizer->SetDrawingMode(drawmode);
|
|
|
|
cam->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// update graphics
|
2006-01-06 03:46:54 +00:00
|
|
|
void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-09-15 00:11:30 +00:00
|
|
|
bool override_camera;
|
2008-09-14 00:32:18 +00:00
|
|
|
RAS_Rect viewport, area;
|
2009-04-26 12:23:30 +00:00
|
|
|
float nearfrust, farfrust, focallength;
|
2006-01-06 03:46:54 +00:00
|
|
|
// KX_Camera* cam = scene->GetActiveCamera();
|
2004-03-22 22:02:18 +00:00
|
|
|
|
|
|
|
if (!cam)
|
|
|
|
return;
|
2008-09-18 01:46:28 +00:00
|
|
|
GetSceneViewport(scene, cam, area, viewport);
|
2008-09-14 00:32:18 +00:00
|
|
|
|
|
|
|
// store the computed viewport in the scene
|
2012-09-16 04:58:18 +00:00
|
|
|
scene->SetSceneViewport(viewport);
|
2008-09-14 00:32:18 +00:00
|
|
|
|
|
|
|
// set the viewport for this frame and scene
|
|
|
|
m_canvas->SetViewPort(viewport.GetLeft(), viewport.GetBottom(),
|
2012-09-16 04:58:18 +00:00
|
|
|
viewport.GetRight(), viewport.GetTop());
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// see KX_BlenderMaterial::Activate
|
|
|
|
//m_rasterizer->SetAmbient();
|
2002-10-12 11:37:38 +00:00
|
|
|
m_rasterizer->DisplayFog();
|
|
|
|
|
2008-09-15 00:11:30 +00:00
|
|
|
override_camera = m_overrideCam && (scene->GetName() == m_overrideSceneName);
|
|
|
|
override_camera = override_camera && (cam->GetName() == "__default__cam__");
|
|
|
|
|
|
|
|
if (override_camera && m_overrideCamUseOrtho) {
|
2009-04-26 12:23:30 +00:00
|
|
|
m_rasterizer->SetProjectionMatrix(m_overrideCamProjMat);
|
|
|
|
if (!cam->hasValidProjectionMatrix()) {
|
|
|
|
// needed to get frustrum planes for culling
|
|
|
|
MT_Matrix4x4 projmat;
|
|
|
|
projmat.setValue(m_overrideCamProjMat.getPointer());
|
|
|
|
cam->SetProjectionMatrix(projmat);
|
|
|
|
}
|
2011-07-25 15:37:55 +00:00
|
|
|
} else if (cam->hasValidProjectionMatrix())
|
2004-05-16 12:53:39 +00:00
|
|
|
{
|
|
|
|
m_rasterizer->SetProjectionMatrix(cam->GetProjectionMatrix());
|
|
|
|
} else
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
RAS_FrameFrustum frustum;
|
2008-09-15 00:11:30 +00:00
|
|
|
bool orthographic = !cam->GetCameraData()->m_perspective;
|
2004-07-20 12:07:06 +00:00
|
|
|
nearfrust = cam->GetCameraNear();
|
|
|
|
farfrust = cam->GetCameraFar();
|
2008-05-24 08:34:04 +00:00
|
|
|
focallength = cam->GetFocalLength();
|
2009-04-26 12:23:30 +00:00
|
|
|
MT_Matrix4x4 projmat;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (override_camera) {
|
2008-09-15 00:11:30 +00:00
|
|
|
nearfrust = m_overrideCamNear;
|
|
|
|
farfrust = m_overrideCamFar;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orthographic) {
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-04-26 12:23:30 +00:00
|
|
|
RAS_FramingManager::ComputeOrtho(
|
|
|
|
scene->GetFramingType(),
|
|
|
|
area,
|
|
|
|
viewport,
|
|
|
|
cam->GetScale(),
|
|
|
|
nearfrust,
|
|
|
|
farfrust,
|
2011-11-04 14:36:06 +00:00
|
|
|
cam->GetSensorFit(),
|
2009-04-26 12:23:30 +00:00
|
|
|
frustum
|
|
|
|
);
|
|
|
|
if (!cam->GetViewport()) {
|
|
|
|
frustum.x1 *= m_cameraZoom;
|
|
|
|
frustum.x2 *= m_cameraZoom;
|
|
|
|
frustum.y1 *= m_cameraZoom;
|
|
|
|
frustum.y2 *= m_cameraZoom;
|
|
|
|
}
|
|
|
|
projmat = m_rasterizer->GetOrthoMatrix(
|
|
|
|
frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
RAS_FramingManager::ComputeFrustum(
|
|
|
|
scene->GetFramingType(),
|
|
|
|
area,
|
|
|
|
viewport,
|
|
|
|
cam->GetLens(),
|
2011-11-04 14:36:06 +00:00
|
|
|
cam->GetSensorWidth(),
|
|
|
|
cam->GetSensorHeight(),
|
|
|
|
cam->GetSensorFit(),
|
2009-04-26 12:23:30 +00:00
|
|
|
nearfrust,
|
|
|
|
farfrust,
|
|
|
|
frustum
|
|
|
|
);
|
2008-09-14 00:32:18 +00:00
|
|
|
|
2009-04-26 12:23:30 +00:00
|
|
|
if (!cam->GetViewport()) {
|
|
|
|
frustum.x1 *= m_cameraZoom;
|
|
|
|
frustum.x2 *= m_cameraZoom;
|
|
|
|
frustum.y1 *= m_cameraZoom;
|
|
|
|
frustum.y2 *= m_cameraZoom;
|
|
|
|
}
|
|
|
|
projmat = m_rasterizer->GetFrustumMatrix(
|
|
|
|
frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar, focallength);
|
|
|
|
}
|
2004-08-10 11:35:38 +00:00
|
|
|
cam->SetProjectionMatrix(projmat);
|
2004-12-01 08:43:58 +00:00
|
|
|
|
|
|
|
// Otherwise the projection matrix for each eye will be the same...
|
2009-04-26 12:23:30 +00:00
|
|
|
if (!orthographic && m_rasterizer->Stereo())
|
2004-08-10 11:35:38 +00:00
|
|
|
cam->InvalidateProjectionMatrix();
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2004-07-20 12:07:06 +00:00
|
|
|
MT_Transform camtrans(cam->GetWorldToCamera());
|
|
|
|
MT_Matrix4x4 viewmat(camtrans);
|
|
|
|
|
2009-04-26 12:23:30 +00:00
|
|
|
m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->GetCameraData()->m_perspective);
|
2002-10-12 11:37:38 +00:00
|
|
|
cam->SetModelviewMatrix(viewmat);
|
|
|
|
|
|
|
|
// The following actually reschedules all vertices to be
|
|
|
|
// redrawn. There is a cache between the actual rescheduling
|
|
|
|
// and this call though. Visibility is imparted when this call
|
|
|
|
// runs through the individual objects.
|
2009-04-07 22:14:06 +00:00
|
|
|
|
|
|
|
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
SG_SetActiveStage(SG_STAGE_CULLING);
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
scene->CalculateVisibleMeshes(m_rasterizer,cam);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-12-17 22:42:47 +00:00
|
|
|
// update levels of detail
|
|
|
|
scene->UpdateObjectLods();
|
|
|
|
|
2009-04-07 22:14:06 +00:00
|
|
|
m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
|
|
|
|
SG_SetActiveStage(SG_STAGE_RENDER);
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-11-22 14:42:22 +00:00
|
|
|
// Run any pre-drawing python callbacks
|
|
|
|
scene->RunDrawingCallbacks(scene->GetPreDrawCB());
|
2010-03-23 21:37:02 +00:00
|
|
|
#endif
|
2009-11-22 14:42:22 +00:00
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
scene->RenderBuckets(camtrans, m_rasterizer);
|
Patch:[#25163] BGE support for Blender Font objects - unicode support
Problem/Bug:
------------
There were no way to have proper unicode characters (e.g. Japanese) in Blender Game Engine. Now we can :)
You can see a sample here: http://blog.mikepan.com/multi-language-support-in-blender/
Functionality Explanation:
--------------------------
This patch converts the Blender Font Objects to a new BGE type: KX_FontObject
This object inherits KX_GameObject.cpp and has the following properties:
- text (the text of the object)
- size (taken from the Blender object, usually is 1.0)
- resolution (1.0 by default, maybe not really needed, but at least for debugging/the time being it's nice to have)
The way we deal with linked objects is different than Blender. In Blender the text and size are a property of the Text databock. Therefore linked objects necessarily share the same text (and size, although the size of the object datablock affects that too). In BGE they are stored and accessed per object. Without that it would be problematic to have addObject adding texts that don't share the same data.
Known problems/limitations/ToDo:
--------------------------------
1) support for packed font and the <builtin>
2) figure why some fonts are displayed in a different size in 3DView/BGE (BLF)
3) investigate some glitches I see some times
4) support for multiline
5) support for more Blender Font Object options (text aligment, text boxes, ...)
[1] Diego (bdiego) evantually will help on that. For the time being we are using the "default" (ui) font to replace the <builtin>.
[2] but not all of them. I need to cross check who is calculating the size/dpi in/correctly - Blender or BLF. (e.g. fonts that work well - MS Gothic)
[3] I think this may be related to the resolution we are drawing the font
[4] It can't/will not be handled inside BFL. So the way I see it is to implement a mini text library/api that works as a middlelayer between the drawing step and BLF.
So instead of:
BLF_draw(fontid, (char *)text, strlen(text));
We would do:
MAGIC_ROUTINE_IM_NOT_BLF_draw(fontir, (char *)text, styleflag, width, height);
[5] don't hold your breath ... but if someone wants to have fun in the holidays the (4) and (5) are part of the same problem.
Code Explanation:
-----------------
The patch should be simple to read. They are three may parts:
1) BL_BlenderDataConversion.cpp:: converts the OB_FONT object into a KX_FontObject.cpp and store it in the KX_Scene->m_fonts
2) KetsjiEngine.cpp::RenderFonts:: loop through the texts and call their internal drawing routine.
3) KX_FontObject.cpp::
a) constructor: load the font of the object, and store other values.
b) DrawText: calculate the aspect for the given size (sounds hacky but this is how blf works) and call the render routine in RenderTools
4) KX_BlenderGL.cpp (called from rendertools) ::BL_print_game_line:: Draws the text. Using the BLF API
*) In order to handle visibility of the object added with AddObject I'm adding to the m_scene.m_fonts list only the Fonts in a visible layer - unlike Cameras and Lamps where all the objects are added.
Acknowledgements:
----------------
Thanks Benoit for the review and adjustment suggestions.
Thanks Diego for the BFL expertise, patches and support (Latin community ftw)
Thanks my boss for letting me do part of this patch during work time. Good thing we are starting a project in a partnership with a Japanese Foundation and eventual will need unicode in BGE :) for more details on that - www.nereusprogram.org - let's call it the main sponsor of this "bug feature" ;)
2010-12-16 10:25:41 +00:00
|
|
|
|
|
|
|
//render all the font objects for this scene
|
2013-06-20 03:50:02 +00:00
|
|
|
scene->RenderFonts();
|
2007-10-22 20:24:26 +00:00
|
|
|
|
2009-03-09 05:01:16 +00:00
|
|
|
if (scene->GetPhysicsEnvironment())
|
BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code.
This is a squashed commit of the following:
BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks.
BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController.
BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController.
BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp.
BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes.
BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject.
BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController.
BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController.
BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController.
BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now.
BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController.
BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController.
BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate.
BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController.
BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController.
BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity().
BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface.
BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController.
BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController.
BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController.
BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation).
BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller.
BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1().
2013-11-04 19:22:47 +00:00
|
|
|
scene->GetPhysicsEnvironment()->DebugDrawWorld();
|
2007-10-22 20:24:26 +00:00
|
|
|
}
|
Patch:[#25163] BGE support for Blender Font objects - unicode support
Problem/Bug:
------------
There were no way to have proper unicode characters (e.g. Japanese) in Blender Game Engine. Now we can :)
You can see a sample here: http://blog.mikepan.com/multi-language-support-in-blender/
Functionality Explanation:
--------------------------
This patch converts the Blender Font Objects to a new BGE type: KX_FontObject
This object inherits KX_GameObject.cpp and has the following properties:
- text (the text of the object)
- size (taken from the Blender object, usually is 1.0)
- resolution (1.0 by default, maybe not really needed, but at least for debugging/the time being it's nice to have)
The way we deal with linked objects is different than Blender. In Blender the text and size are a property of the Text databock. Therefore linked objects necessarily share the same text (and size, although the size of the object datablock affects that too). In BGE they are stored and accessed per object. Without that it would be problematic to have addObject adding texts that don't share the same data.
Known problems/limitations/ToDo:
--------------------------------
1) support for packed font and the <builtin>
2) figure why some fonts are displayed in a different size in 3DView/BGE (BLF)
3) investigate some glitches I see some times
4) support for multiline
5) support for more Blender Font Object options (text aligment, text boxes, ...)
[1] Diego (bdiego) evantually will help on that. For the time being we are using the "default" (ui) font to replace the <builtin>.
[2] but not all of them. I need to cross check who is calculating the size/dpi in/correctly - Blender or BLF. (e.g. fonts that work well - MS Gothic)
[3] I think this may be related to the resolution we are drawing the font
[4] It can't/will not be handled inside BFL. So the way I see it is to implement a mini text library/api that works as a middlelayer between the drawing step and BLF.
So instead of:
BLF_draw(fontid, (char *)text, strlen(text));
We would do:
MAGIC_ROUTINE_IM_NOT_BLF_draw(fontir, (char *)text, styleflag, width, height);
[5] don't hold your breath ... but if someone wants to have fun in the holidays the (4) and (5) are part of the same problem.
Code Explanation:
-----------------
The patch should be simple to read. They are three may parts:
1) BL_BlenderDataConversion.cpp:: converts the OB_FONT object into a KX_FontObject.cpp and store it in the KX_Scene->m_fonts
2) KetsjiEngine.cpp::RenderFonts:: loop through the texts and call their internal drawing routine.
3) KX_FontObject.cpp::
a) constructor: load the font of the object, and store other values.
b) DrawText: calculate the aspect for the given size (sounds hacky but this is how blf works) and call the render routine in RenderTools
4) KX_BlenderGL.cpp (called from rendertools) ::BL_print_game_line:: Draws the text. Using the BLF API
*) In order to handle visibility of the object added with AddObject I'm adding to the m_scene.m_fonts list only the Fonts in a visible layer - unlike Cameras and Lamps where all the objects are added.
Acknowledgements:
----------------
Thanks Benoit for the review and adjustment suggestions.
Thanks Diego for the BFL expertise, patches and support (Latin community ftw)
Thanks my boss for letting me do part of this patch during work time. Good thing we are starting a project in a partnership with a Japanese Foundation and eventual will need unicode in BGE :) for more details on that - www.nereusprogram.org - let's call it the main sponsor of this "bug feature" ;)
2010-12-16 10:25:41 +00:00
|
|
|
|
2010-03-03 06:38:47 +00:00
|
|
|
/*
|
2012-03-09 18:28:30 +00:00
|
|
|
* To run once per scene
|
|
|
|
*/
|
2010-03-03 06:38:47 +00:00
|
|
|
void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene)
|
2007-10-22 20:24:26 +00:00
|
|
|
{
|
2011-09-01 19:53:14 +00:00
|
|
|
// We need to first make sure our viewport is correct (enabling multiple viewports can mess this up)
|
|
|
|
m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
|
2012-05-21 18:35:31 +00:00
|
|
|
|
|
|
|
m_rasterizer->FlushDebugShapes();
|
2010-03-03 06:38:47 +00:00
|
|
|
scene->Render2DFilters(m_canvas);
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2012-09-16 04:58:18 +00:00
|
|
|
scene->RunDrawingCallbacks(scene->GetPostDrawCB());
|
2010-03-23 21:37:02 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::StopEngine()
|
|
|
|
{
|
|
|
|
if (m_bInitialized)
|
|
|
|
{
|
2005-11-06 16:50:22 +00:00
|
|
|
|
2010-02-22 12:25:58 +00:00
|
|
|
if (m_animation_record)
|
2005-11-06 16:50:22 +00:00
|
|
|
{
|
|
|
|
// printf("TestHandlesPhysicsObjectToAnimationIpo\n");
|
|
|
|
m_sceneconverter->TestHandlesPhysicsObjectToAnimationIpo();
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_SceneList::iterator sceneit;
|
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++)
|
|
|
|
{
|
|
|
|
KX_Scene* scene = *sceneit;
|
2008-03-09 21:42:03 +00:00
|
|
|
m_sceneconverter->RemoveScene(scene);
|
2012-09-16 04:58:18 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
m_scenes.clear();
|
|
|
|
|
2012-09-16 04:58:18 +00:00
|
|
|
// cleanup all the stuff
|
2002-10-12 11:37:38 +00:00
|
|
|
m_rasterizer->Exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scene Management is able to switch between scenes
|
|
|
|
// and have several scene's running in parallel
|
|
|
|
void KX_KetsjiEngine::AddScene(KX_Scene* scene)
|
|
|
|
{
|
|
|
|
m_scenes.push_back(scene);
|
|
|
|
PostProcessScene(scene);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene)
|
|
|
|
{
|
|
|
|
bool override_camera = (m_overrideCam && (scene->GetName() == m_overrideSceneName));
|
2009-04-07 22:14:06 +00:00
|
|
|
|
|
|
|
SG_SetActiveStage(SG_STAGE_SCENE);
|
|
|
|
|
|
|
|
// if there is no activecamera, or the camera is being
|
|
|
|
// overridden we need to construct a temporarily camera
|
2002-10-12 11:37:38 +00:00
|
|
|
if (!scene->GetActiveCamera() || override_camera)
|
|
|
|
{
|
|
|
|
KX_Camera* activecam = NULL;
|
|
|
|
|
2004-04-08 12:01:48 +00:00
|
|
|
RAS_CameraData camdata = RAS_CameraData();
|
2011-10-20 06:38:45 +00:00
|
|
|
if (override_camera)
|
|
|
|
{
|
|
|
|
camdata.m_lens = m_overrideCamLens;
|
|
|
|
camdata.m_clipstart = m_overrideCamNear;
|
|
|
|
camdata.m_clipend = m_overrideCamFar;
|
|
|
|
|
|
|
|
camdata.m_perspective= !m_overrideCamUseOrtho;
|
|
|
|
}
|
2009-04-07 22:14:06 +00:00
|
|
|
activecam = new KX_Camera(scene,KX_Scene::m_callbacks,camdata);
|
2002-10-12 11:37:38 +00:00
|
|
|
activecam->SetName("__default__cam__");
|
|
|
|
|
|
|
|
// set transformation
|
|
|
|
if (override_camera) {
|
|
|
|
const MT_CmMatrix4x4& cammatdata = m_overrideCamViewMat;
|
|
|
|
MT_Transform trans = MT_Transform(cammatdata.getPointer());
|
|
|
|
MT_Transform camtrans;
|
|
|
|
camtrans.invert(trans);
|
|
|
|
|
|
|
|
activecam->NodeSetLocalPosition(camtrans.getOrigin());
|
|
|
|
activecam->NodeSetLocalOrientation(camtrans.getBasis());
|
2009-04-07 22:14:06 +00:00
|
|
|
activecam->NodeUpdateGS(0);
|
2002-10-12 11:37:38 +00:00
|
|
|
} else {
|
|
|
|
activecam->NodeSetLocalPosition(MT_Point3(0.0, 0.0, 0.0));
|
|
|
|
activecam->NodeSetLocalOrientation(MT_Vector3(0.0, 0.0, 0.0));
|
2009-04-07 22:14:06 +00:00
|
|
|
activecam->NodeUpdateGS(0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
scene->AddCamera(activecam);
|
|
|
|
scene->SetActiveCamera(activecam);
|
|
|
|
scene->GetObjectList()->Add(activecam->AddRef());
|
|
|
|
scene->GetRootParentList()->Add(activecam->AddRef());
|
2008-03-01 19:46:50 +00:00
|
|
|
//done with activecam
|
|
|
|
activecam->Release();
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
scene->UpdateParents(0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::RenderDebugProperties()
|
|
|
|
{
|
|
|
|
STR_String debugtxt;
|
2012-10-30 22:45:08 +00:00
|
|
|
int title_xmargin = -7;
|
|
|
|
int title_y_top_margin = 4;
|
|
|
|
int title_y_bottom_margin = 2;
|
|
|
|
|
|
|
|
int const_xindent = 4;
|
|
|
|
int const_ysize = 14;
|
|
|
|
|
|
|
|
int xcoord = 12; // mmmm, these constants were taken from blender source
|
|
|
|
int ycoord = 17; // to 'mimic' behavior
|
|
|
|
|
2013-01-28 01:26:36 +00:00
|
|
|
int profile_indent = 72;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
float tottime = m_logger->GetAverage();
|
|
|
|
if (tottime < 1e-6f) {
|
|
|
|
tottime = 1e-6f;
|
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// Set viewport to entire canvas
|
|
|
|
RAS_Rect viewport;
|
|
|
|
m_canvas->SetViewPort(0, 0, int(m_canvas->GetWidth()), int(m_canvas->GetHeight()));
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-01-12 16:49:37 +00:00
|
|
|
if (m_show_framerate || m_show_profile) {
|
2012-10-30 22:45:08 +00:00
|
|
|
/* Title for profiling("Profile") */
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
|
2013-01-12 16:49:37 +00:00
|
|
|
"Profile",
|
|
|
|
xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin
|
|
|
|
ycoord,
|
|
|
|
m_canvas->GetWidth() /* RdV, TODO ?? */,
|
|
|
|
m_canvas->GetHeight() /* RdV, TODO ?? */);
|
2012-10-30 22:45:08 +00:00
|
|
|
|
|
|
|
// Increase the indent by default increase
|
|
|
|
ycoord += const_ysize;
|
|
|
|
// Add the title indent afterwards
|
|
|
|
ycoord += title_y_bottom_margin;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Framerate display */
|
|
|
|
if (m_show_framerate) {
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
|
2013-01-12 16:49:37 +00:00
|
|
|
"Frametime :",
|
|
|
|
xcoord + const_xindent,
|
|
|
|
ycoord,
|
|
|
|
m_canvas->GetWidth() /* RdV, TODO ?? */,
|
|
|
|
m_canvas->GetHeight() /* RdV, TODO ?? */);
|
2012-10-30 22:45:08 +00:00
|
|
|
|
2013-01-28 01:26:36 +00:00
|
|
|
debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.f, 1.0/tottime);
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
|
2013-01-12 16:49:37 +00:00
|
|
|
debugtxt.ReadPtr(),
|
|
|
|
xcoord + const_xindent + profile_indent,
|
|
|
|
ycoord,
|
|
|
|
m_canvas->GetWidth() /* RdV, TODO ?? */,
|
|
|
|
m_canvas->GetHeight() /* RdV, TODO ?? */);
|
2012-10-30 22:45:08 +00:00
|
|
|
// Increase the indent by default increase
|
|
|
|
ycoord += const_ysize;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 22:45:08 +00:00
|
|
|
/* Profile display */
|
2013-01-12 16:49:37 +00:00
|
|
|
if (m_show_profile) {
|
|
|
|
for (int j = tc_first; j < tc_numCategories; j++) {
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
|
2013-01-12 16:49:37 +00:00
|
|
|
m_profileLabels[j],
|
2012-10-30 22:45:08 +00:00
|
|
|
xcoord + const_xindent,
|
2013-01-12 16:49:37 +00:00
|
|
|
ycoord,
|
2012-06-17 09:58:26 +00:00
|
|
|
m_canvas->GetWidth(),
|
|
|
|
m_canvas->GetHeight());
|
2012-10-30 22:45:08 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
double time = m_logger->GetAverage((KX_TimeCategory)j);
|
2012-10-30 22:45:08 +00:00
|
|
|
|
2013-01-28 01:26:36 +00:00
|
|
|
debugtxt.Format("%5.2fms | %d%%", time*1000.f, (int)(time/tottime * 100.f));
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
|
2013-01-12 16:49:37 +00:00
|
|
|
debugtxt.ReadPtr(),
|
2012-10-30 22:45:08 +00:00
|
|
|
xcoord + const_xindent + profile_indent, ycoord,
|
2012-06-17 09:58:26 +00:00
|
|
|
m_canvas->GetWidth(),
|
|
|
|
m_canvas->GetHeight());
|
2013-01-28 01:26:36 +00:00
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime);
|
2012-10-30 22:45:08 +00:00
|
|
|
ycoord += const_ysize;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-30 22:45:08 +00:00
|
|
|
// Add the ymargin for titles below the other section of debug info
|
|
|
|
ycoord += title_y_top_margin;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* Property display*/
|
2013-07-09 20:06:36 +00:00
|
|
|
if (m_show_debug_properties) {
|
2012-10-30 22:45:08 +00:00
|
|
|
|
|
|
|
/* Title for debugging("Debug properties") */
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
|
2013-01-12 17:12:48 +00:00
|
|
|
"Debug Properties",
|
2013-01-12 16:49:37 +00:00
|
|
|
xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin
|
|
|
|
ycoord,
|
|
|
|
m_canvas->GetWidth() /* RdV, TODO ?? */,
|
|
|
|
m_canvas->GetHeight() /* RdV, TODO ?? */);
|
2012-10-30 22:45:08 +00:00
|
|
|
|
|
|
|
// Increase the indent by default increase
|
|
|
|
ycoord += const_ysize;
|
|
|
|
// Add the title indent afterwards
|
|
|
|
ycoord += title_y_bottom_margin;
|
|
|
|
|
2013-07-09 20:06:36 +00:00
|
|
|
/* Calculate amount of properties that can displayed. */
|
|
|
|
unsigned propsAct = 0;
|
|
|
|
unsigned propsMax = (m_canvas->GetHeight() - ycoord) / const_ysize;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_SceneList::iterator sceneit;
|
2013-01-12 16:49:37 +00:00
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) {
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_Scene* scene = *sceneit;
|
|
|
|
/* the 'normal' debug props */
|
|
|
|
vector<SCA_DebugProp*>& debugproplist = scene->GetDebugProperties();
|
|
|
|
|
2013-07-09 20:06:36 +00:00
|
|
|
for (unsigned i=0; i < debugproplist.size() && propsAct < propsMax; i++)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2013-07-09 20:06:36 +00:00
|
|
|
CValue *propobj = debugproplist[i]->m_obj;
|
2002-10-12 11:37:38 +00:00
|
|
|
STR_String objname = propobj->GetName();
|
2013-07-09 20:06:36 +00:00
|
|
|
STR_String propname = debugproplist[i]->m_name;
|
|
|
|
propsAct++;
|
2013-01-12 16:49:37 +00:00
|
|
|
if (propname == "__state__") {
|
2008-09-25 16:19:07 +00:00
|
|
|
// reserve name for object state
|
|
|
|
KX_GameObject* gameobj = static_cast<KX_GameObject*>(propobj);
|
|
|
|
unsigned int state = gameobj->GetState();
|
|
|
|
debugtxt = objname + "." + propname + " = ";
|
|
|
|
bool first = true;
|
|
|
|
for (int statenum=1;state;state >>= 1, statenum++)
|
|
|
|
{
|
|
|
|
if (state & 1)
|
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
{
|
|
|
|
debugtxt += ",";
|
|
|
|
}
|
|
|
|
debugtxt += STR_String(statenum);
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
|
2013-01-12 16:49:37 +00:00
|
|
|
debugtxt.ReadPtr(),
|
|
|
|
xcoord + const_xindent,
|
|
|
|
ycoord,
|
|
|
|
m_canvas->GetWidth(),
|
|
|
|
m_canvas->GetHeight());
|
2012-10-30 22:45:08 +00:00
|
|
|
ycoord += const_ysize;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-01-12 16:49:37 +00:00
|
|
|
else {
|
|
|
|
CValue *propval = propobj->GetProperty(propname);
|
|
|
|
if (propval) {
|
2008-09-25 16:19:07 +00:00
|
|
|
STR_String text = propval->GetText();
|
2012-10-30 22:45:08 +00:00
|
|
|
debugtxt = objname + ": '" + propname + "' = " + text;
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
|
2013-01-12 16:49:37 +00:00
|
|
|
debugtxt.ReadPtr(),
|
|
|
|
xcoord + const_xindent,
|
|
|
|
ycoord,
|
|
|
|
m_canvas->GetWidth(),
|
|
|
|
m_canvas->GetHeight());
|
2012-10-30 22:45:08 +00:00
|
|
|
ycoord += const_ysize;
|
2008-09-25 16:19:07 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_SceneList* KX_KetsjiEngine::CurrentScenes()
|
|
|
|
{
|
2012-09-16 04:58:18 +00:00
|
|
|
return &m_scenes;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KX_Scene* KX_KetsjiEngine::FindScene(const STR_String& scenename)
|
|
|
|
{
|
|
|
|
KX_SceneList::iterator sceneit = m_scenes.begin();
|
|
|
|
|
|
|
|
// bit risky :) better to split the second clause
|
|
|
|
while ( (sceneit != m_scenes.end())
|
|
|
|
&& ((*sceneit)->GetName() != scenename))
|
|
|
|
{
|
|
|
|
sceneit++;
|
|
|
|
}
|
|
|
|
|
2012-09-16 04:58:18 +00:00
|
|
|
return ((sceneit == m_scenes.end()) ? NULL : *sceneit);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::ConvertAndAddScene(const STR_String& scenename,bool overlay)
|
|
|
|
{
|
|
|
|
// only add scene when it doesn't exist!
|
2013-01-12 16:49:37 +00:00
|
|
|
if (FindScene(scenename)) {
|
|
|
|
printf("warning: scene %s already exists, not added!\n",scenename.ReadPtr());
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-01-12 16:49:37 +00:00
|
|
|
else {
|
|
|
|
if (overlay) {
|
2013-06-18 04:15:27 +00:00
|
|
|
m_addingOverlayScenes.push_back(scenename);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-01-12 16:49:37 +00:00
|
|
|
else {
|
2013-06-18 04:15:27 +00:00
|
|
|
m_addingBackgroundScenes.push_back(scenename);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::RemoveScene(const STR_String& scenename)
|
|
|
|
{
|
|
|
|
if (FindScene(scenename))
|
|
|
|
{
|
2013-06-18 04:15:27 +00:00
|
|
|
m_removingScenes.push_back(scenename);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-03-22 22:02:18 +00:00
|
|
|
// STR_String tmpname = scenename;
|
|
|
|
std::cout << "warning: scene " << scenename << " does not exist, not removed!" << std::endl;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::RemoveScheduledScenes()
|
|
|
|
{
|
|
|
|
if (m_removingScenes.size())
|
|
|
|
{
|
2013-06-18 04:15:27 +00:00
|
|
|
vector<STR_String>::iterator scenenameit;
|
2002-10-12 11:37:38 +00:00
|
|
|
for (scenenameit=m_removingScenes.begin();scenenameit != m_removingScenes.end();scenenameit++)
|
|
|
|
{
|
|
|
|
STR_String scenename = *scenenameit;
|
|
|
|
|
|
|
|
KX_SceneList::iterator sceneit;
|
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++)
|
|
|
|
{
|
|
|
|
KX_Scene* scene = *sceneit;
|
|
|
|
if (scene->GetName()==scenename)
|
|
|
|
{
|
2008-03-09 21:42:03 +00:00
|
|
|
m_sceneconverter->RemoveScene(scene);
|
2002-10-12 11:37:38 +00:00
|
|
|
m_scenes.erase(sceneit);
|
|
|
|
break;
|
|
|
|
}
|
2012-09-16 04:58:18 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
m_removingScenes.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-18 20:56:25 +00:00
|
|
|
KX_Scene* KX_KetsjiEngine::CreateScene(Scene *scene, bool libloading)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
KX_Scene* tmpscene = new KX_Scene(m_keyboarddevice,
|
|
|
|
m_mousedevice,
|
|
|
|
m_networkdevice,
|
2009-11-15 23:58:56 +00:00
|
|
|
scene->id.name+2,
|
2010-04-23 22:48:26 +00:00
|
|
|
scene,
|
|
|
|
m_canvas);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-07-30 21:42:29 +00:00
|
|
|
m_sceneconverter->ConvertScene(tmpscene,
|
2013-11-04 19:21:07 +00:00
|
|
|
m_rasterizer,
|
2012-12-18 20:56:25 +00:00
|
|
|
m_canvas,
|
|
|
|
libloading);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
return tmpscene;
|
|
|
|
}
|
|
|
|
|
2009-11-15 23:58:56 +00:00
|
|
|
KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename)
|
|
|
|
{
|
|
|
|
Scene *scene = m_sceneconverter->GetBlenderSceneForName(scenename);
|
2014-03-25 00:57:02 +00:00
|
|
|
if (!scene)
|
|
|
|
return NULL;
|
2009-11-15 23:58:56 +00:00
|
|
|
return CreateScene(scene);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
void KX_KetsjiEngine::AddScheduledScenes()
|
|
|
|
{
|
2013-06-18 04:15:27 +00:00
|
|
|
vector<STR_String>::iterator scenenameit;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (m_addingOverlayScenes.size())
|
|
|
|
{
|
|
|
|
for (scenenameit = m_addingOverlayScenes.begin();
|
|
|
|
scenenameit != m_addingOverlayScenes.end();
|
|
|
|
scenenameit++)
|
|
|
|
{
|
|
|
|
STR_String scenename = *scenenameit;
|
|
|
|
KX_Scene* tmpscene = CreateScene(scenename);
|
2014-03-25 00:57:02 +00:00
|
|
|
if (tmpscene) {
|
|
|
|
m_scenes.push_back(tmpscene);
|
|
|
|
PostProcessScene(tmpscene);
|
|
|
|
} else {
|
|
|
|
printf("warning: scene %s could not be found, not added!\n",scenename.ReadPtr());
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
m_addingOverlayScenes.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_addingBackgroundScenes.size())
|
|
|
|
{
|
|
|
|
for (scenenameit = m_addingBackgroundScenes.begin();
|
|
|
|
scenenameit != m_addingBackgroundScenes.end();
|
|
|
|
scenenameit++)
|
|
|
|
{
|
|
|
|
STR_String scenename = *scenenameit;
|
|
|
|
KX_Scene* tmpscene = CreateScene(scenename);
|
2014-03-25 00:57:02 +00:00
|
|
|
if (tmpscene) {
|
|
|
|
m_scenes.insert(m_scenes.begin(),tmpscene);
|
|
|
|
PostProcessScene(tmpscene);
|
|
|
|
} else {
|
|
|
|
printf("warning: scene %s could not be found, not added!\n",scenename.ReadPtr());
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
m_addingBackgroundScenes.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::ReplaceScene(const STR_String& oldscene,const STR_String& newscene)
|
|
|
|
{
|
2013-06-18 04:15:27 +00:00
|
|
|
m_replace_scenes.push_back(std::make_pair(oldscene,newscene));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// replace scene is not the same as removing and adding because the
|
|
|
|
// scene must be in exact the same place (to maintain drawingorder)
|
|
|
|
// (nzc) - should that not be done with a scene-display list? It seems
|
|
|
|
// stupid to rely on the mem allocation order...
|
|
|
|
void KX_KetsjiEngine::ReplaceScheduledScenes()
|
|
|
|
{
|
|
|
|
if (m_replace_scenes.size())
|
|
|
|
{
|
2013-06-18 04:15:27 +00:00
|
|
|
vector<pair<STR_String,STR_String> >::iterator scenenameit;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
for (scenenameit = m_replace_scenes.begin();
|
|
|
|
scenenameit != m_replace_scenes.end();
|
|
|
|
scenenameit++)
|
|
|
|
{
|
|
|
|
STR_String oldscenename = (*scenenameit).first;
|
|
|
|
STR_String newscenename = (*scenenameit).second;
|
|
|
|
int i=0;
|
|
|
|
/* Scenes are not supposed to be included twice... I think */
|
|
|
|
KX_SceneList::iterator sceneit;
|
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++)
|
|
|
|
{
|
|
|
|
KX_Scene* scene = *sceneit;
|
|
|
|
if (scene->GetName() == oldscenename)
|
|
|
|
{
|
2008-03-09 21:42:03 +00:00
|
|
|
m_sceneconverter->RemoveScene(scene);
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_Scene* tmpscene = CreateScene(newscenename);
|
|
|
|
m_scenes[i]=tmpscene;
|
|
|
|
PostProcessScene(tmpscene);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_replace_scenes.clear();
|
2012-09-16 04:58:18 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SuspendScene(const STR_String& scenename)
|
|
|
|
{
|
|
|
|
KX_Scene* scene = FindScene(scenename);
|
|
|
|
if (scene) scene->Suspend();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::ResumeScene(const STR_String& scenename)
|
|
|
|
{
|
|
|
|
KX_Scene* scene = FindScene(scenename);
|
|
|
|
if (scene) scene->Resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetUseFixedTime(bool bUseFixedTime)
|
|
|
|
{
|
|
|
|
m_bFixedTime = bUseFixedTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-22 12:25:58 +00:00
|
|
|
void KX_KetsjiEngine::SetAnimRecordMode(bool animation_record, int startFrame)
|
2005-08-23 13:16:02 +00:00
|
|
|
{
|
2010-02-22 12:25:58 +00:00
|
|
|
m_animation_record = animation_record;
|
|
|
|
if (animation_record)
|
2005-10-30 07:25:36 +00:00
|
|
|
{
|
2012-04-05 03:05:02 +00:00
|
|
|
//when recording physics keyframes, run at a variable (capped) frame rate (fixed time == full speed)
|
|
|
|
m_bFixedTime = false;
|
2005-10-30 07:25:36 +00:00
|
|
|
}
|
2005-08-23 13:16:02 +00:00
|
|
|
m_currentFrame = startFrame;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
bool KX_KetsjiEngine::GetUseFixedTime(void) const
|
|
|
|
{
|
|
|
|
return m_bFixedTime;
|
|
|
|
}
|
|
|
|
|
2005-12-18 19:10:26 +00:00
|
|
|
double KX_KetsjiEngine::GetSuspendedDelta()
|
|
|
|
{
|
|
|
|
return m_suspendeddelta;
|
|
|
|
}
|
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
double KX_KetsjiEngine::GetTicRate()
|
|
|
|
{
|
|
|
|
return m_ticrate;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
void KX_KetsjiEngine::SetTicRate(double ticrate)
|
|
|
|
{
|
|
|
|
m_ticrate = ticrate;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-05-01 16:35:06 +00:00
|
|
|
int KX_KetsjiEngine::GetMaxLogicFrame()
|
|
|
|
{
|
|
|
|
return m_maxLogicFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetMaxLogicFrame(int frame)
|
|
|
|
{
|
|
|
|
m_maxLogicFrame = frame;
|
|
|
|
}
|
|
|
|
|
2009-05-21 18:10:19 +00:00
|
|
|
int KX_KetsjiEngine::GetMaxPhysicsFrame()
|
|
|
|
{
|
|
|
|
return m_maxPhysicsFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetMaxPhysicsFrame(int frame)
|
|
|
|
{
|
|
|
|
m_maxPhysicsFrame = frame;
|
|
|
|
}
|
|
|
|
|
2011-08-12 20:53:29 +00:00
|
|
|
bool KX_KetsjiEngine::GetRestrictAnimationFPS()
|
|
|
|
{
|
|
|
|
return m_restrict_anim_fps;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetRestrictAnimationFPS(bool bRestrictAnimFPS)
|
|
|
|
{
|
|
|
|
m_restrict_anim_fps = bRestrictAnimFPS;
|
|
|
|
}
|
|
|
|
|
2008-06-17 10:06:38 +00:00
|
|
|
double KX_KetsjiEngine::GetAnimFrameRate()
|
|
|
|
{
|
|
|
|
return m_anim_framerate;
|
|
|
|
}
|
|
|
|
|
2008-10-31 21:06:48 +00:00
|
|
|
double KX_KetsjiEngine::GetClockTime(void) const
|
|
|
|
{
|
|
|
|
return m_clockTime;
|
|
|
|
}
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
double KX_KetsjiEngine::GetFrameTime(void) const
|
|
|
|
{
|
|
|
|
return m_frameTime;
|
|
|
|
}
|
|
|
|
|
2009-05-23 14:40:36 +00:00
|
|
|
double KX_KetsjiEngine::GetRealTime(void) const
|
|
|
|
{
|
|
|
|
return m_kxsystem->GetTimeInSeconds();
|
|
|
|
}
|
|
|
|
|
2008-06-17 10:06:38 +00:00
|
|
|
void KX_KetsjiEngine::SetAnimFrameRate(double framerate)
|
|
|
|
{
|
|
|
|
m_anim_framerate = framerate;
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
double KX_KetsjiEngine::GetAverageFrameRate()
|
|
|
|
{
|
|
|
|
return m_average_framerate;
|
|
|
|
}
|
|
|
|
|
Cucumber, first batch of merge - UI changes and custom exit key
---------------------------------------------------------------
This was a test drive to see how painful the merge will be.
Next batches are:
- use desktop option for fullscreen
- multisampling option
- bullet collision mask
- python
- storage (vbo, dl, ...)
- lighting
[lighting still needs review]
[python could use review, although it should be straightforward]
[storage should be tested more I think]
Merged /branches/soc-2011-cucumber:r
36991,37059,37157,37416,37497-37499,37501,37522,39036,40593
36991:
==UI==
* Made some options available in Blender Game that were only available in Blender Render (camera resolution, animation fps)
* Created a panel for the embedded player
* Renamed the FPS option for the standalone player to Refresh Rate
* Moved framing options to display
* Made a button to launch the blender player from within blender (only tested on windows for now)
37059:
==UI==
* Added the option to change the exit key for the BGE. The UI currently just sets a number, and this feature most likely does not work for blenderplayer yet. More work on this to come.
* Removed the physics settings from the scene panel for the BGE.
* Added an Add menu in the logic brick header.
37157:
Making the bake options available in Blender Game
37416:
Making the exit key UI element accept key presses instead of numbers. It still does not work for the Blenderplayer, and it does not limit the input to key presses (other events don't work for exiting)
37497:
Some more work on getting the exit key to work in the Blenderplayer.
Input is now restricted to keyboard events only for the exit key UI.
37498:
Some clean up from the last commit.
The exit key setting affects the Blenderplayer now.
37499:
Cleaning up some duplicate code. Now the reverseTranslateTable for converting blender key codes to ketsji key codes is only defined in BL_BlenderDataConverter.
37501:
Centralizing the exit key methods to the keyboard devices. This should make it easier to get exit key control to the python API.
[37517: committed previously]
37522:
Moved control of the exit key away from the keyboard devices, and moved it to ketsjiengine.
Added setExitKey and getExitKey to the python API
39036:
A couple of the doversions were in the wrong spot. This should fix some issues with the exit key not being set.
[not committed entirely, see below]]
40552: space_logic.py (* fixed an error in space_logic.py *)
40593:
launch blenderplayer from ui not working in OSX fix - by Daniel Stokes and me
########################################################
code left behind (to be included in next commit):
########################################################
{
/* Initialize default values for collision masks */
Object *ob;
for(ob=main->object.first; ob; ob=ob->id.next)
ob->col_group = ob->col_mask = 1;
}
2011-12-20 03:11:56 +00:00
|
|
|
void KX_KetsjiEngine::SetExitKey(short key)
|
|
|
|
{
|
|
|
|
m_exitkey = key;
|
|
|
|
}
|
|
|
|
|
|
|
|
short KX_KetsjiEngine::GetExitKey()
|
|
|
|
{
|
|
|
|
return m_exitkey;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void KX_KetsjiEngine::SetTimingDisplay(bool frameRate, bool profile, bool properties)
|
|
|
|
{
|
|
|
|
m_show_framerate = frameRate;
|
|
|
|
m_show_profile = profile;
|
|
|
|
m_show_debug_properties = properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::GetTimingDisplay(bool& frameRate, bool& profile, bool& properties) const
|
|
|
|
{
|
|
|
|
frameRate = m_show_framerate;
|
|
|
|
profile = m_show_profile;
|
|
|
|
properties = m_show_debug_properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::ProcessScheduledScenes(void)
|
|
|
|
{
|
|
|
|
// Check whether there will be changes to the list of scenes
|
|
|
|
if (m_addingOverlayScenes.size() ||
|
|
|
|
m_addingBackgroundScenes.size() ||
|
|
|
|
m_replace_scenes.size() ||
|
|
|
|
m_removingScenes.size()) {
|
|
|
|
|
|
|
|
// Change the scene list
|
|
|
|
ReplaceScheduledScenes();
|
|
|
|
RemoveScheduledScenes();
|
|
|
|
AddScheduledScenes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetHideCursor(bool hideCursor)
|
|
|
|
{
|
|
|
|
m_hideCursor = hideCursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KX_KetsjiEngine::GetHideCursor(void) const
|
|
|
|
{
|
|
|
|
return m_hideCursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetUseOverrideFrameColor(bool overrideFrameColor)
|
|
|
|
{
|
|
|
|
m_overrideFrameColor = overrideFrameColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KX_KetsjiEngine::GetUseOverrideFrameColor(void) const
|
|
|
|
{
|
|
|
|
return m_overrideFrameColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::SetOverrideFrameColor(float r, float g, float b)
|
|
|
|
{
|
|
|
|
m_overrideFrameColorR = r;
|
|
|
|
m_overrideFrameColorG = g;
|
|
|
|
m_overrideFrameColorB = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KX_KetsjiEngine::GetOverrideFrameColor(float& r, float& g, float& b) const
|
|
|
|
{
|
|
|
|
r = m_overrideFrameColorR;
|
|
|
|
g = m_overrideFrameColorG;
|
|
|
|
b = m_overrideFrameColorB;
|
|
|
|
}
|
|
|
|
|
2013-04-12 01:52:30 +00:00
|
|
|
|
|
|
|
void KX_KetsjiEngine::Resize()
|
|
|
|
{
|
|
|
|
KX_SceneList::iterator sceneit;
|
|
|
|
|
|
|
|
/* extended mode needs to recalculate camera frustrums when */
|
|
|
|
KX_Scene* firstscene = *m_scenes.begin();
|
|
|
|
const RAS_FrameSettings &framesettings = firstscene->GetFramingType();
|
|
|
|
|
|
|
|
if (framesettings.FrameType() == RAS_FrameSettings::e_frame_extend) {
|
|
|
|
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) {
|
|
|
|
KX_Camera* cam = ((KX_Scene *)*sceneit)->GetActiveCamera();
|
|
|
|
cam->InvalidateProjectionMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-11 05:54:07 +00:00
|
|
|
void KX_KetsjiEngine::SetGlobalSettings(GlobalSettings* gs)
|
|
|
|
{
|
|
|
|
m_globalsettings.matmode = gs->matmode;
|
|
|
|
m_globalsettings.glslflag = gs->glslflag;
|
|
|
|
}
|
|
|
|
|
|
|
|
GlobalSettings* KX_KetsjiEngine::GetGlobalSettings(void)
|
|
|
|
{
|
|
|
|
return &m_globalsettings;
|
|
|
|
}
|
2007-09-29 18:51:01 +00:00
|
|
|
|