diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2016-01-09 11:47:33 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2016-01-09 11:47:33 +0300 |
commit | 18affe39a53fb0c7e74c001b988fd953756a927d (patch) | |
tree | b76a8f9e558b148e82a13c5f7abac203815f98ac /source/gameengine | |
parent | 18829ee54ae970b3fd2dec74a1d89c24d3085961 (diff) | |
parent | 2d973f44e2fd47fa2fd4c1f59247c56517fcb26c (diff) |
Merge remote-tracking branch 'origin/master' into decklink
Diffstat (limited to 'source/gameengine')
102 files changed, 1468 insertions, 2858 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 88a716e7878..91683f4d6e7 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -54,7 +54,6 @@ #include "KX_PyConstraintBinding.h" #include "KX_PythonMain.h" -#include "RAS_GLExtensionManager.h" #include "RAS_OpenGLRasterizer.h" #include "RAS_ListRasterizer.h" @@ -250,12 +249,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */ #endif - - bgl::InitExtensions(true); - - // VBO code for derived mesh is not compatible with BGE (couldn't find why), so disable - int disableVBO = (U.gameflags & USER_DISABLE_VBO); - U.gameflags |= USER_DISABLE_VBO; // Globals to be carried on over blender files GlobalSettings gs; @@ -306,12 +299,20 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c canvas->SetSwapInterval((startscene->gm.vsync == VSYNC_ON) ? 1 : 0); RAS_IRasterizer* rasterizer = NULL; + RAS_STORAGE_TYPE raster_storage = RAS_AUTO_STORAGE; + + if (startscene->gm.raster_storage == RAS_STORE_VBO) { + raster_storage = RAS_VBO; + } + else if (startscene->gm.raster_storage == RAS_STORE_VA) { + raster_storage = RAS_VA; + } //Don't use displaylists with VBOs //If auto starts using VBOs, make sure to check for that here - if (displaylists && startscene->gm.raster_storage != RAS_STORE_VBO) - rasterizer = new RAS_ListRasterizer(canvas, true, startscene->gm.raster_storage); + if (displaylists && raster_storage != RAS_VBO) + rasterizer = new RAS_ListRasterizer(canvas, true, raster_storage); else - rasterizer = new RAS_OpenGLRasterizer(canvas, startscene->gm.raster_storage); + rasterizer = new RAS_OpenGLRasterizer(canvas, raster_storage); RAS_IRasterizer::MipmapOption mipmapval = rasterizer->GetMipmapping(); @@ -677,14 +678,12 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); - if (!disableVBO) - U.gameflags &= ~USER_DISABLE_VBO; - if (bfd) BLO_blendfiledata_free(bfd); BLI_strncpy(G.main->name, oldsce, sizeof(G.main->name)); #ifdef WITH_PYTHON + PyDict_Clear(pyGlobalDict); Py_DECREF(pyGlobalDict); // Release Python's GIL diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index e37818678d6..927b26faf8a 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -35,23 +35,16 @@ #include "KX_BlenderCanvas.h" -#include "DNA_image_types.h" -#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" #include "BKE_image.h" -#include "BKE_global.h" -#include "BKE_main.h" - -#include "BLI_path_util.h" -#include "BLI_string.h" #include <assert.h> +#include <iostream> extern "C" { -#include "IMB_imbuf.h" -#include "IMB_imbuf_types.h" #include "WM_api.h" #include "wm_cursors.h" #include "wm_window.h" @@ -341,33 +334,20 @@ void KX_BlenderCanvas::MakeScreenShot(const char *filename) area_dummy.totrct.ymax = m_frame_rect.GetTop(); dumprect = screenshot(&area_dummy, &dumpsx, &dumpsy); - - if (dumprect) { - /* initialize image file format data */ - Scene *scene = (screen)? screen->scene: NULL; - ImageFormatData im_format; - - if (scene) - im_format = scene->r.im_format; - else - BKE_imformat_defaults(&im_format); - - /* create file path */ - char path[FILE_MAX]; - BLI_strncpy(path, filename, sizeof(path)); - BLI_path_abs(path, G.main->name); - BLI_path_frame(path, m_frame, 0); - m_frame++; - BKE_image_path_ensure_ext_from_imtype(path, im_format.imtype); - - /* create and save imbuf */ - ImBuf *ibuf = IMB_allocImBuf(dumpsx, dumpsy, 24, 0); - ibuf->rect = dumprect; - - BKE_imbuf_write_as(ibuf, path, &im_format, false); - - ibuf->rect = NULL; - IMB_freeImBuf(ibuf); - MEM_freeN(dumprect); + if (!dumprect) { + std::cerr << "KX_BlenderCanvas: Unable to take screenshot!" << std::endl; + return; } + + /* initialize image file format data */ + Scene *scene = (screen)? screen->scene: NULL; + ImageFormatData *im_format = (ImageFormatData *)MEM_mallocN(sizeof(ImageFormatData), "im_format"); + + if (scene) + *im_format = scene->r.im_format; + else + BKE_imformat_defaults(im_format); + + /* save_screenshot() frees dumprect and im_format */ + save_screenshot(filename, dumpsx, dumpsy, dumprect, im_format); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index 817a667d783..6f408f86551 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -212,7 +212,6 @@ private: RAS_Rect m_area_rect; int m_area_left; int m_area_top; - int m_frame; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript deleted file mode 100644 index ea14092943a..00000000000 --- a/source/gameengine/BlenderRoutines/SConscript +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('*.cpp') - -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -incs = [ - '.', - '#intern/container', - '#intern/guardedalloc', - '#intern/string', - '#source/blender', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - '#intern/ghost/include', - '#intern/moto/include', - '#source/blender/blenfont', - '#source/blender/blenkernel', - '#source/blender/blenlib', - '#source/blender/blenloader', - '#source/blender/gpu', - '#source/blender/imbuf', - '#source/blender/makesdna', - '#source/blender/makesrna', - '#source/blender/misc', - '#source/blender/windowmanager', - '#source/gameengine/Converter', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Ketsji', - '#source/gameengine/Network', - '#source/gameengine/Rasterizer', - '#source/gameengine/SceneGraph', - '#source/blender/editors/include', - '#source/gameengine/Network/LoopBackNetwork', - '#source/gameengine/Physics/Bullet', - '#source/gameengine/Physics/common', - '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - ] -incs = ' '.join(incs) - -if env['WITH_BF_AUDASPACE']: - defs += env['BF_AUDASPACE_DEF'] - incs += ' ' + env['BF_AUDASPACE_C_INC'] - -if env['WITH_BF_FFMPEG']: - defs.append('WITH_FFMPEG') - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - -incs += ' ' + env['BF_BULLET_INC'] -incs += ' ' + env['BF_OPENGL_INC'] -incs += ' ' + env['BF_BOOST_INC'] - -if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): - incs += ' ' + env['BF_PTHREADS_INC'] - -env.BlenderLib ( 'ge_blen_routines', sources, Split(incs), defs, libtype=['core','player'], priority=[300,35] , cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 6cbb8e08cf5..ad1fdf2f06a 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -1438,18 +1438,18 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene *kx_scene, /* ensure all materials are tagged */ for (int i = 0; i < mesh->totcol; i++) { if (mesh->mat[i]) - mesh->mat[i]->id.flag &= ~LIB_DOIT; + mesh->mat[i]->id.tag &= ~LIB_TAG_DOIT; } for (int i = 0; i < mesh->totcol; i++) { Material *mat_old = mesh->mat[i]; /* if its tagged its a replaced material */ - if (mat_old && (mat_old->id.flag & LIB_DOIT) == 0) { + if (mat_old && (mat_old->id.tag & LIB_TAG_DOIT) == 0) { Material *mat_old = mesh->mat[i]; Material *mat_new = BKE_material_copy(mat_old); - mat_new->id.flag |= LIB_DOIT; + mat_new->id.tag |= LIB_TAG_DOIT; id_us_min(&mat_old->id); BLI_remlink(&G.main->mat, mat_new); // BKE_material_copy uses G.main, and there is no BKE_material_copy_ex diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript deleted file mode 100644 index 6336fcd3906..00000000000 --- a/source/gameengine/Converter/SConscript +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('*.cpp') -defs = [] - -incs = [ - '.', - '#extern/Eigen3', - '#intern/container', - '#intern/guardedalloc', - '#intern/string', - '#source/blender', - '#intern/moto/include', - '#source/blender/blenkernel', - '#source/blender/blenlib', - '#source/blender/blenloader', - '#source/blender/gpu', - '#source/blender/ikplugin', - '#source/blender/imbuf', - '#source/blender/makesdna', - '#source/blender/makesrna', - '#source/blender/misc', - '#source/blender/windowmanager', - '#source/gameengine/BlenderRoutines', - '#source/gameengine/Converter', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Ketsji', - '#source/gameengine/Network', - '#source/gameengine/Rasterizer', - '#source/gameengine/SceneGraph', - '#extern/recastnavigation/Detour/Include', - '#source/blender/editors/include', - '#source/gameengine/Ketsji/KXNetwork', - '#source/gameengine/Network/LoopBackNetwork', - '#source/gameengine/Physics/Bullet', - '#source/gameengine/Physics/Dummy', - '#source/gameengine/Physics/common', - '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - ] -incs = ' '.join(incs) - -incs += ' ' + env['BF_BULLET_INC'] -incs += ' ' + env['BF_BOOST_INC'] - -if env['BF_DEBUG']: - if env['OURPLATFORM'] in ('win32-mingw', 'win32-vc', 'win64-vc', 'win64-mingw'): - defs.append('_DEBUG') - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -if env['WITH_BF_AUDASPACE']: - defs += env['BF_AUDASPACE_DEF'] - incs += ' ' + env['BF_AUDASPACE_C_INC'] - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - -if env['WITH_BF_BULLET']: - defs.append('WITH_BULLET') - -if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): - incs += ' ' + env['BF_PTHREADS_INC'] - -env.BlenderLib ( 'ge_converter', sources, Split(incs), defs, libtype=['core','player'], priority=[305,40], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Expressions/SConscript b/source/gameengine/Expressions/SConscript deleted file mode 100644 index b66d36c2080..00000000000 --- a/source/gameengine/Expressions/SConscript +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('intern/*.cpp') - -incs = [ - '.', - '#intern/guardedalloc', - '#intern/string', - '#intern/moto/include', - '#source/gameengine/SceneGraph', - '#source/blender/blenlib', - ] - -defs = [] - -if env['WITH_BF_PYTHON']: - incs.extend(Split(env['BF_PYTHON_INC'])) - defs.append('WITH_PYTHON') - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - -env.BlenderLib('ge_logic_expressions', sources, incs, defs, libtype=['core','player'], priority = [360,80], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript deleted file mode 100644 index 0ecd08d3495..00000000000 --- a/source/gameengine/GameLogic/SConscript +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp') - -incs = [ - '.', - '#intern/container', - '#intern/ghost', - '#/intern/string', - '#/intern/moto/include', - '#/source/blender/blenlib', - '#/source/gameengine/Expressions', - '#/source/gameengine/Rasterizer', - '#/source/gameengine/SceneGraph', - ] -incs = ' '.join(incs) - -defs = [] - -if env['WITH_BF_SDL']: - defs.append('WITH_SDL') - incs += ' ' + env['BF_SDL_INC'] - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): - if env['BF_DEBUG']: - defs.append('_DEBUG') - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - incs += ' #/intern/guardedalloc' - -env.BlenderLib ( 'ge_logic', sources, Split(incs), defs, libtype=['core','player'], priority=[330,65], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/GamePlayer/SConscript b/source/gameengine/GamePlayer/SConscript deleted file mode 100644 index d1930aca26d..00000000000 --- a/source/gameengine/GamePlayer/SConscript +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -SConscript(['common/SConscript', - 'ghost/SConscript']) diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp index 52c4d13c638..2b355407d46 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp @@ -30,31 +30,14 @@ */ -#ifndef NOPNG -#ifdef WIN32 -#include "png.h" -#else -#include <png.h> -#endif -#endif // NOPNG - #include "RAS_IPolygonMaterial.h" #include "GPC_Canvas.h" -#include "BLI_path_util.h" -#include "BLI_string.h" - #include "DNA_scene_types.h" #include "DNA_space_types.h" -#include "BKE_global.h" -#include "BKE_main.h" #include "BKE_image.h" - -extern "C" { -#include "IMB_imbuf.h" -#include "IMB_imbuf_types.h" -} +#include "MEM_guardedalloc.h" GPC_Canvas::GPC_Canvas( @@ -164,37 +147,22 @@ MakeScreenShot( const char* filename ) { // copy image data - unsigned char *pixels = new unsigned char[GetWidth() * GetHeight() * 4]; + unsigned int dumpsx = GetWidth(); + unsigned int dumpsy = GetHeight(); + unsigned int *pixels = (unsigned int *)MEM_mallocN(sizeof(int) * dumpsx * dumpsy, "pixels"); if (!pixels) { std::cout << "Cannot allocate pixels array" << std::endl; return; } - glReadPixels(0, 0, GetWidth(), GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, pixels); + glReadPixels(0, 0, dumpsx, dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // initialize image file format data - ImageFormatData im_format; - BKE_imformat_defaults(&im_format); - - // create file path - char path[FILE_MAX]; - BLI_strncpy(path, filename, sizeof(path)); - BLI_path_abs(path, G.main->name); - BLI_path_frame(path, m_frame, 0); - m_frame++; - BKE_image_path_ensure_ext_from_imtype(path, im_format.imtype); - - // create and save imbuf - ImBuf *ibuf = IMB_allocImBuf(GetWidth(), GetHeight(), 24, 0); - ibuf->rect = (unsigned int*)pixels; - - BKE_imbuf_write_as(ibuf, path, &im_format, false); - - ibuf->rect = NULL; - IMB_freeImBuf(ibuf); + ImageFormatData *im_format = (ImageFormatData *)MEM_mallocN(sizeof(ImageFormatData), "im_format"); + BKE_imformat_defaults(im_format); - // clean up - delete [] (pixels); + /* save_screenshot() frees dumprect and im_format */ + save_screenshot(filename, dumpsx, dumpsy, pixels, im_format); } diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index 34cc9759a08..9a108203ee8 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -56,8 +56,6 @@ protected: /** Rect that defines the area used for rendering, * relative to the context */ RAS_Rect m_displayarea; - /** Frame counter for screenshots */ - int m_frame; int m_viewport[4]; diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript deleted file mode 100644 index dc105491c98..00000000000 --- a/source/gameengine/GamePlayer/common/SConscript +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -import sys -Import ('env') - - -source_files = [ - 'GPC_Canvas.cpp', - 'GPC_KeyboardDevice.cpp', - 'GPC_MouseDevice.cpp', - ] - -incs = [ - '.', - '#intern/string', - '#intern/ghost', - '#intern/guardedalloc', - '#intern/moto/include', - '#intern/container', - '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - '#source/gameengine/Converter', - '#source/gameengine/BlenderRoutines', - '#source/blender/imbuf', - '#source/gameengine/Ketsji', - '#source/blender/blenlib', - '#source/blender/blenfont', - '#source/blender/blenkernel', - '#source/blender', - '#source/blender/include', - '#source/blender/makesdna', - '#source/gameengine/Rasterizer', - '#source/gameengine/GameLogic', - '#source/gameengine/Expressions', - '#source/gameengine/Network', - '#source/gameengine/SceneGraph', - '#source/gameengine/Physics/common', - '#source/gameengine/Network/LoopBackNetwork', - '#source/gameengine/GamePlayer/ghost', - '#source/blender/misc', - '#source/blender/blenloader', - '#source/blender/gpu', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - ] - -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -if env['WITH_BF_PYTHON']: - incs.extend(Split(env['BF_PYTHON_INC'])) - defs.append('WITH_PYTHON') - -incs.extend(Split(env['BF_PNG_INC'])) -incs.extend(Split(env['BF_ZLIB_INC'])) - -env.BlenderLib (libname='ge_player_common', sources=source_files, includes=incs, defines = defs, libtype=['player'], priority=[5], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 179180580ae..1b52c61b816 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -78,7 +78,6 @@ extern "C" #include "RAS_MeshObject.h" #include "RAS_OpenGLRasterizer.h" #include "RAS_ListRasterizer.h" -#include "RAS_GLExtensionManager.h" #include "KX_PythonInit.h" #include "KX_PyConstraintBinding.h" #include "BL_Material.h" // MAXTEX @@ -570,7 +569,6 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (!m_engineInitialized) { GPU_init(); - bgl::InitExtensions(true); // get and set the preferences SYS_SystemHandle syshandle = SYS_GetSystem(); @@ -614,12 +612,20 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (gm->flag & GAME_SHOW_MOUSE) m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); + RAS_STORAGE_TYPE raster_storage = RAS_AUTO_STORAGE; + + if (gm->raster_storage == RAS_STORE_VBO) { + raster_storage = RAS_VBO; + } + else if (gm->raster_storage == RAS_STORE_VA) { + raster_storage = RAS_VA; + } //Don't use displaylists with VBOs //If auto starts using VBOs, make sure to check for that here - if (useLists && gm->raster_storage != RAS_STORE_VBO) - m_rasterizer = new RAS_ListRasterizer(m_canvas, false, gm->raster_storage); + if (useLists && raster_storage != RAS_VBO) + m_rasterizer = new RAS_ListRasterizer(m_canvas, true, raster_storage); else - m_rasterizer = new RAS_OpenGLRasterizer(m_canvas, gm->raster_storage); + m_rasterizer = new RAS_OpenGLRasterizer(m_canvas, raster_storage); /* Stereo parameters - Eye Separation from the UI - stereomode from the command-line/UI */ m_rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) stereoMode); diff --git a/source/gameengine/GamePlayer/ghost/GPG_System.cpp b/source/gameengine/GamePlayer/ghost/GPG_System.cpp index 6710572d843..669ab0532d9 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_System.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_System.cpp @@ -46,7 +46,7 @@ double GPG_System::GetTimeInSeconds() { GHOST_TInt64 millis = (GHOST_TInt64)m_system->getMilliSeconds(); double time = (double)millis; - time /= 1000.0f; + time /= 1000.0; return time; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index c46446ada82..52ebe2c9633 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -458,7 +458,6 @@ int main(int argc, char** argv) initglobals(); - U.gameflags |= USER_DISABLE_VBO; // We load our own G.main, so free the one that initglobals() gives us BKE_main_free(G.main); G.main = NULL; diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript deleted file mode 100644 index be9f50f40fb..00000000000 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -import sys -Import ('env') - -source_files = [ - 'GPG_Application.cpp', - 'GPG_Canvas.cpp', - 'GPG_ghost.cpp', - 'GPG_KeyboardDevice.cpp', - 'GPG_System.cpp', - ] - -incs = [ - '.', - '#intern/string', - '#intern/ghost', - '#intern/guardedalloc', - '#intern/memutil', - '#intern/moto/include', - '#intern/container', - '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - '#source/gameengine/BlenderRoutines', - '#source/gameengine/Converter', - '#source/blender/imbuf', - '#source/gameengine/Ketsji', - '#source/blender/blenfont', - '#source/blender/blenlib', - '#source/blender/blenkernel', - '#source/blender/blentranslation', - '#source/blender', - '#source/blender/include', - '#source/blender/makesdna', - '#source/blender/makesrna', - '#source/gameengine/Rasterizer', - '#source/gameengine/GameLogic', - '#source/gameengine/Expressions', - '#source/gameengine/Network', - '#source/gameengine/SceneGraph', - '#source/gameengine/Physics/common', - '#source/gameengine/Network/LoopBackNetwork', - '#source/gameengine/GamePlayer/common', - '#source/blender/misc', - '#source/blender/blenloader', - '#source/blender/gpu', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - ] - -incs.append(env['BF_PTHREADS_INC']) -incs.append(env['BF_BOOST_INC']) - -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -if env['WITH_BF_PYTHON']: - incs += Split(env['BF_PYTHON_INC']) - defs.append('WITH_PYTHON') - -if env['WITH_BF_AUDASPACE']: - defs += env['BF_AUDASPACE_DEF'] - incs.append(env['BF_AUDASPACE_C_INC']) - -if env['WITH_BF_FFMPEG']: - defs.append('WITH_FFMPEG') - -if env['WITH_BF_INTERNATIONAL']: - defs.append('WITH_INTERNATIONAL') - -if env['WITH_BF_SDL'] and env['WITH_BF_SDL_DYNLOAD']: - defs.append('WITH_SDL_DYNLOAD') - incs += ['#extern/sdlew/include'] - -env.BlenderLib (libname='ge_player_ghost', sources=source_files, includes = incs, defines = defs, libtype=['player'],priority=[0], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 89d8ec0d4ca..45946f30827 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -342,7 +342,7 @@ void BL_Action::SetTimes(float start, float end) void BL_Action::SetLocalTime(float curtime) { - float dt = (curtime-m_starttime)*KX_KetsjiEngine::GetAnimFrameRate()*m_speed; + float dt = (curtime-m_starttime)*(float)KX_KetsjiEngine::GetAnimFrameRate()*m_speed; if (m_endframe < m_startframe) dt = -dt; @@ -354,7 +354,7 @@ void BL_Action::ResetStartTime(float curtime) { float dt = (m_localframe > m_startframe) ? m_localframe - m_startframe : m_startframe - m_localframe; - m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed); + m_starttime = curtime - dt / ((float)KX_KetsjiEngine::GetAnimFrameRate()*m_speed); SetLocalTime(curtime); } @@ -365,7 +365,7 @@ void BL_Action::IncrementBlending(float curtime) m_blendstart = curtime; // Bump the blend frame - m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate(); + m_blendframe = (curtime - m_blendstart)*(float)KX_KetsjiEngine::GetAnimFrameRate(); // Clamp if (m_blendframe>m_blendin) @@ -398,7 +398,7 @@ void BL_Action::Update(float curtime) if (m_done) return; - curtime -= KX_KetsjiEngine::GetSuspendedDelta(); + curtime -= (float)KX_KetsjiEngine::GetSuspendedDelta(); // Grab the start time here so we don't end up with a negative m_localframe when // suspending and resuming scenes. diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp index 491be035d66..35f605f1a5f 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.cpp +++ b/source/gameengine/Ketsji/BL_ActionManager.cpp @@ -28,7 +28,7 @@ #include "BL_ActionManager.h" #include "DNA_ID.h" -#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->flag & LIB_DOIT)) +#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT)) BL_ActionManager::BL_ActionManager(class KX_GameObject *obj): m_obj(obj), diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index b5151615f3b..0f71f8d3bac 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -35,8 +35,8 @@ #include "BL_BlenderShader.h" #include "BL_Material.h" -#include "GPU_extensions.h" #include "GPU_material.h" +#include "GPU_shader.h" #include "RAS_BucketManager.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 0b4a48a59b3..324463be569 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -35,7 +35,6 @@ #include "KX_PythonInit.h" #include "MEM_guardedalloc.h" -#include "RAS_GLExtensionManager.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 8f717c05c0f..0b0a0f5d403 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -38,7 +38,6 @@ #include "BKE_image.h" #include "BLI_blenlib.h" -#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" #include "RAS_ICanvas.h" #include "RAS_Rect.h" @@ -196,7 +195,7 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap) { - if (!GPU_non_power_of_two_support() && (!is_power_of_2_i(x) || !is_power_of_2_i(y)) ) { + if (!GPU_full_non_power_of_two_support() && (!is_power_of_2_i(x) || !is_power_of_2_i(y)) ) { InitNonPow2Tex(pix, x,y,mipmap); return; } @@ -686,7 +685,7 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate) glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand); } break; } - glTexEnvf( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0); + glTexEnvf( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f); glEndList(); } diff --git a/source/gameengine/Ketsji/KXNetwork/SConscript b/source/gameengine/Ketsji/KXNetwork/SConscript deleted file mode 100644 index ab03e03e74d..00000000000 --- a/source/gameengine/Ketsji/KXNetwork/SConscript +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('*.cpp') - -incs = [ - '.', - '#intern/container', - '#intern/string', - '#intern/moto/include', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Ketsji', - '#source/gameengine/Network', - '#source/gameengine/SceneGraph', - '../../../blender/blenlib', - ] -incs = ' '.join(incs) - -defs = [] - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -env.BlenderLib ( 'bf_network', Split(sources), Split(incs), defines=defs,libtype=['core','player'], priority=[400,125], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index d85d33d9834..1d185d52dc8 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -39,7 +39,6 @@ #include "RAS_BucketManager.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" -#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" #include "GPU_draw.h" @@ -676,13 +675,13 @@ void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const mMaterial->matcolor[0]*mMaterial->emit, mMaterial->matcolor[1]*mMaterial->emit, mMaterial->matcolor[2]*mMaterial->emit, - 1.0 ); + 1.0f ); rasty->SetAmbient(mMaterial->amb); } if (mMaterial->material) - rasty->SetPolygonOffset(-mMaterial->material->zoffs, 0.0); + rasty->SetPolygonOffset(-mMaterial->material->zoffs, 0.0f); } diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 644c71a68e4..6988d563808 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -294,7 +294,7 @@ void KX_Camera::NormalizeClipPlanes() for (unsigned int p = 0; p < 6; p++) { - MT_Scalar factor = sqrt(m_planes[p][0]*m_planes[p][0] + m_planes[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]); + MT_Scalar factor = sqrtf(m_planes[p][0]*m_planes[p][0] + m_planes[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]); if (!MT_fuzzyZero(factor)) m_planes[p] /= factor; } @@ -318,21 +318,21 @@ void KX_Camera::ExtractFrustumSphere() MT_Matrix4x4 clip_camcs_matrix = m_projection_matrix; clip_camcs_matrix.invert(); - if (m_projection_matrix[3][3] == MT_Scalar(0.0)) + if (m_projection_matrix[3][3] == MT_Scalar(0.0f)) { // frustrum projection // detect which of the corner of the far clipping plane is the farthest to the origin MT_Vector4 nfar; // far point in device normalized coordinate MT_Point3 farpoint; // most extreme far point in camera coordinate MT_Point3 nearpoint;// most extreme near point in camera coordinate - MT_Point3 farcenter(0.0, 0.0, 0.0);// center of far cliping plane in camera coordinate - MT_Scalar F=-1.0, N; // square distance of far and near point to origin + MT_Point3 farcenter(0.0f, 0.0f, 0.0f);// center of far cliping plane in camera coordinate + MT_Scalar F=-1.0f, N; // square distance of far and near point to origin MT_Scalar f, n; // distance of far and near point to z axis. f is always > 0 but n can be < 0 MT_Scalar e, s; // far and near clipping distance (<0) MT_Scalar c; // slope of center line = distance of far clipping center to z axis / far clipping distance MT_Scalar z; // projection of sphere center on z axis (<0) // tmp value - MT_Vector4 npoint(1.0, 1.0, 1.0, 1.0); + MT_Vector4 npoint(1.0f, 1.0f, 1.0f, 1.0f); MT_Vector4 hpoint; MT_Point3 point; MT_Scalar len; @@ -354,9 +354,9 @@ void KX_Camera::ExtractFrustumSphere() farcenter += point; } // the far center is the average of the far clipping points - farcenter *= 0.25; + farcenter *= 0.25f; // the extreme near point is the opposite point on the near clipping plane - nfar.setValue(-nfar[0], -nfar[1], -1.0, 1.0); + nfar.setValue(-nfar[0], -nfar[1], -1.0f, 1.0f); nfar = clip_camcs_matrix*nfar; nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]); // this is a frustrum projection @@ -373,7 +373,7 @@ void KX_Camera::ExtractFrustumSphere() n = f*s/e - MT_Point2(nearpoint[0]-farxy[0], nearpoint[1]-farxy[1]).length(); c = MT_Point2(farcenter[0], farcenter[1]).length()/e; // the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case - z = (F-N)/(2.0*(e-s+c*(f-n))); + z = (F-N)/(2.0f*(e-s+c*(f-n))); m_frustum_center = MT_Point3(farcenter[0]*z/e, farcenter[1]*z/e, z); m_frustum_radius = m_frustum_center.distance(farpoint); } @@ -381,7 +381,7 @@ void KX_Camera::ExtractFrustumSphere() { // orthographic projection // The most extreme points on the near and far plane. (normalized device coords) - MT_Vector4 hnear(1.0, 1.0, 1.0, 1.0), hfar(-1.0, -1.0, -1.0, 1.0); + MT_Vector4 hnear(1.0f, 1.0f, 1.0f, 1.0f), hfar(-1.0f, -1.0f, -1.0f, 1.0f); // Transform to hom camera local space hnear = clip_camcs_matrix*hnear; @@ -392,12 +392,12 @@ void KX_Camera::ExtractFrustumSphere() MT_Point3 farpoint(hfar[0]/hfar[3], hfar[1]/hfar[3], hfar[2]/hfar[3]); // just use mediant point - m_frustum_center = (farpoint + nearpoint)*0.5; + m_frustum_center = (farpoint + nearpoint)*0.5f; m_frustum_radius = m_frustum_center.distance(farpoint); } // Transform to world space. m_frustum_center = GetCameraToWorld()(m_frustum_center); - m_frustum_radius /= fabs(NodeGetWorldScaling()[NodeGetWorldScaling().closestAxis()]); + m_frustum_radius /= fabsf(NodeGetWorldScaling()[NodeGetWorldScaling().closestAxis()]); m_set_frustum_center = true; } @@ -408,7 +408,7 @@ bool KX_Camera::PointInsideFrustum(const MT_Point3& x) for ( unsigned int i = 0; i < 6 ; i++ ) { - if (m_planes[i][0] * x[0] + m_planes[i][1] * x[1] + m_planes[i][2] * x[2] + m_planes[i][3] < 0.0) + if (m_planes[i][0] * x[0] + m_planes[i][1] * x[1] + m_planes[i][2] * x[2] + m_planes[i][3] < 0.0f) return false; } return true; @@ -426,7 +426,7 @@ int KX_Camera::BoxInsideFrustum(const MT_Point3 *box) // 8 box vertices. for (unsigned int v = 0; v < 8 ; v++) { - if (m_planes[p][0] * box[v][0] + m_planes[p][1] * box[v][1] + m_planes[p][2] * box[v][2] + m_planes[p][3] < 0.0) + if (m_planes[p][0] * box[v][0] + m_planes[p][1] * box[v][1] + m_planes[p][2] * box[v][2] + m_planes[p][3] < 0.0f) behindCount++; } @@ -463,7 +463,7 @@ int KX_Camera::SphereInsideFrustum(const MT_Point3& center, const MT_Scalar &rad for (p = 0; p < 6; p++) { distance = m_planes[p][0]*center[0] + m_planes[p][1]*center[1] + m_planes[p][2]*center[2] + m_planes[p][3]; - if (fabs(distance) <= radius) + if (fabsf(distance) <= radius) intersect = INTERSECT; else if (distance < -radius) return OUTSIDE; @@ -781,7 +781,7 @@ PyObject *KX_Camera::pyattr_get_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attr float lens = self->m_camdata.m_lens; float width = self->m_camdata.m_sensor_x; - float fov = 2.0 * atan(0.5 * width / lens); + float fov = 2.0f * atanf(0.5f * width / lens); return PyFloat_FromDouble(fov * MT_DEGS_PER_RAD); } @@ -790,14 +790,14 @@ int KX_Camera::pyattr_set_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, P { KX_Camera* self = static_cast<KX_Camera*>(self_v); float fov = PyFloat_AsDouble(value); - if (fov <= 0.0) { + if (fov <= 0.0f) { PyErr_SetString(PyExc_AttributeError, "camera.fov = float: KX_Camera, expected a float greater than zero"); return PY_SET_ATTR_FAIL; } fov *= MT_RADS_PER_DEG; float width = self->m_camdata.m_sensor_x; - float lens = width / (2.0 * tan(0.5 * fov)); + float lens = width / (2.0f * tanf(0.5f * fov)); self->m_camdata.m_lens= lens; self->m_set_projection_matrix = false; @@ -1065,7 +1065,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition, vect[0] = (win[0] - viewport[0]) / viewport[2]; vect[1] = (win[1] - viewport[1]) / viewport[3]; - vect[1] = 1.0 - vect[1]; //to follow Blender window coordinate system (Top-Down) + vect[1] = 1.0f - vect[1]; //to follow Blender window coordinate system (Top-Down) PyObject *ret = PyTuple_New(2); if (ret) { diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index fecd60eb212..27c074393b4 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -96,10 +96,10 @@ KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj, m_refDirection[2] /= len; m_refDirVector /= len; } - m_minimumBound = cos(minBound); - m_maximumBound = cos(maxBound); - m_minimumSine = sin(minBound); - m_maximumSine = sin(maxBound); + m_minimumBound = cosf(minBound); + m_maximumBound = cosf(maxBound); + m_minimumSine = sinf(minBound); + m_maximumSine = sinf(maxBound); } break; default: @@ -188,9 +188,9 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) int axis, sign; if (m_posDampTime) { - filter = m_posDampTime/(1.0+m_posDampTime); + filter = m_posDampTime/(1.0f+m_posDampTime); } else { - filter = 0.0; + filter = 0.0f; } switch (m_locrot) { case KX_ACT_CONSTRAINT_ORIX: @@ -232,10 +232,10 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) if (MT_fuzzyZero2(zaxis.length2())) { // direction and refDirection are identical, // choose any other direction to define plane - if (direction[0] < 0.9999) - zaxis = m_refDirVector.cross(MT_Vector3(1.0,0.0,0.0)); + if (direction[0] < 0.9999f) + zaxis = m_refDirVector.cross(MT_Vector3(1.0f,0.0f,0.0f)); else - zaxis = m_refDirVector.cross(MT_Vector3(0.0,1.0,0.0)); + zaxis = m_refDirVector.cross(MT_Vector3(0.0f,1.0f,0.0f)); } MT_Vector3 yaxis = zaxis.cross(m_refDirVector); yaxis.normalize(); @@ -251,7 +251,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) refDirection = m_refDirVector; } // apply damping on the direction - direction = filter*direction + (1.0-filter)*refDirection; + direction = filter*direction + (1.0f-filter)*refDirection; obj->AlignAxisToVect(direction, axis); result = true; goto CHECK_TIME; @@ -312,22 +312,22 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } else { switch (m_locrot) { case KX_ACT_CONSTRAINT_DIRPX: - direction = MT_Vector3(1.0,0.0,0.0); + direction = MT_Vector3(1.0f,0.0f,0.0f); break; case KX_ACT_CONSTRAINT_DIRPY: - direction = MT_Vector3(0.0,1.0,0.0); + direction = MT_Vector3(0.0f,1.0f,0.0f); break; case KX_ACT_CONSTRAINT_DIRPZ: - direction = MT_Vector3(0.0,0.0,1.0); + direction = MT_Vector3(0.0f,0.0f,1.0f); break; case KX_ACT_CONSTRAINT_DIRNX: - direction = MT_Vector3(-1.0,0.0,0.0); + direction = MT_Vector3(-1.0f,0.0f,0.0f); break; case KX_ACT_CONSTRAINT_DIRNY: - direction = MT_Vector3(0.0,-1.0,0.0); + direction = MT_Vector3(0.0f,-1.0f,0.0f); break; case KX_ACT_CONSTRAINT_DIRNZ: - direction = MT_Vector3(0.0,0.0,-1.0); + direction = MT_Vector3(0.0f,0.0f,-1.0f); break; } } @@ -361,11 +361,11 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) MT_Scalar rotFilter; // apply damping on the direction if (m_rotDampTime) { - rotFilter = m_rotDampTime/(1.0+m_rotDampTime); + rotFilter = m_rotDampTime/(1.0f+m_rotDampTime); } else { rotFilter = filter; } - newnormal = rotFilter*normal - (1.0-rotFilter)*newnormal; + newnormal = rotFilter*normal - (1.0f-rotFilter)*newnormal; obj->AlignAxisToVect((sign)?-newnormal:newnormal, axis); if (m_option & KX_ACT_CONSTRAINT_LOCAL) { direction = newnormal; @@ -374,7 +374,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } if (m_option & KX_ACT_CONSTRAINT_DISTANCE) { if (m_posDampTime) { - newdistance = filter*(position-callback.m_hitPoint).length()+(1.0-filter)*m_minimumBound; + newdistance = filter*(position-callback.m_hitPoint).length()+(1.0f-filter)*m_minimumBound; } else { newdistance = m_minimumBound; } @@ -410,37 +410,37 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) normal[0] = -rotation[0][0]; normal[1] = -rotation[1][0]; normal[2] = -rotation[2][0]; - direction = MT_Vector3(1.0,0.0,0.0); + direction = MT_Vector3(1.0f,0.0f,0.0f); break; case KX_ACT_CONSTRAINT_FHPY: normal[0] = -rotation[0][1]; normal[1] = -rotation[1][1]; normal[2] = -rotation[2][1]; - direction = MT_Vector3(0.0,1.0,0.0); + direction = MT_Vector3(0.0f,1.0f,0.0f); break; case KX_ACT_CONSTRAINT_FHPZ: normal[0] = -rotation[0][2]; normal[1] = -rotation[1][2]; normal[2] = -rotation[2][2]; - direction = MT_Vector3(0.0,0.0,1.0); + direction = MT_Vector3(0.0f,0.0f,1.0f); break; case KX_ACT_CONSTRAINT_FHNX: normal[0] = rotation[0][0]; normal[1] = rotation[1][0]; normal[2] = rotation[2][0]; - direction = MT_Vector3(-1.0,0.0,0.0); + direction = MT_Vector3(-1.0f,0.0f,0.0f); break; case KX_ACT_CONSTRAINT_FHNY: normal[0] = rotation[0][1]; normal[1] = rotation[1][1]; normal[2] = rotation[2][1]; - direction = MT_Vector3(0.0,-1.0,0.0); + direction = MT_Vector3(0.0f,-1.0f,0.0f); break; case KX_ACT_CONSTRAINT_FHNZ: normal[0] = rotation[0][2]; normal[1] = rotation[1][2]; normal[2] = rotation[2][2]; - direction = MT_Vector3(0.0,0.0,-1.0); + direction = MT_Vector3(0.0f,0.0f,-1.0f); break; } normal.normalize(); @@ -475,7 +475,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) MT_Vector3 velocityHitPoint = m_hitObject->GetVelocity(relativeHitPoint); MT_Vector3 relativeVelocity = spc->GetLinearVelocity() - velocityHitPoint; MT_Scalar relativeVelocityRay = direction.dot(relativeVelocity); - MT_Scalar springExtent = 1.0 - distance/m_minimumBound; + MT_Scalar springExtent = 1.0f - distance/m_minimumBound; // Fh force is stored in m_maximum MT_Scalar springForce = springExtent * m_maximumBound; // damping is stored in m_refDirection [0] = damping, [1] = rot damping @@ -520,7 +520,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } result = true; if (m_posDampTime) { - newposition = filter*position + (1.0-filter)*newposition; + newposition = filter*position + (1.0f-filter)*newposition; } obj->NodeSetLocalPosition(newposition); goto CHECK_TIME; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 2220430dba9..8d078eb46b3 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -400,19 +400,19 @@ void KX_Dome::GLDrawWarpQuads(void) glColor3f(warp.nodes[i][j+1].i, warp.nodes[i][j+1].i, warp.nodes[i][j+1].i); glTexCoord2f((warp.nodes[i][j+1].u * uv_width), (warp.nodes[i][j+1].v * uv_height)); - glVertex3f(warp.nodes[i][j+1].x, warp.nodes[i][j+1].y,0.0); + glVertex3f(warp.nodes[i][j+1].x, warp.nodes[i][j+1].y,0.0f); glColor3f(warp.nodes[i+1][j+1].i, warp.nodes[i+1][j+1].i, warp.nodes[i+1][j+1].i); glTexCoord2f((warp.nodes[i+1][j+1].u * uv_width), (warp.nodes[i+1][j+1].v * uv_height)); - glVertex3f(warp.nodes[i+1][j+1].x, warp.nodes[i+1][j+1].y,0.0); + glVertex3f(warp.nodes[i+1][j+1].x, warp.nodes[i+1][j+1].y,0.0f); glColor3f(warp.nodes[i+1][j].i, warp.nodes[i+1][j].i, warp.nodes[i+1][j].i); glTexCoord2f((warp.nodes[i+1][j].u * uv_width), (warp.nodes[i+1][j].v * uv_height)); - glVertex3f(warp.nodes[i+1][j].x, warp.nodes[i+1][j].y,0.0); + glVertex3f(warp.nodes[i+1][j].x, warp.nodes[i+1][j].y,0.0f); glColor3f(warp.nodes[i][j].i, warp.nodes[i][j].i, warp.nodes[i][j].i); glTexCoord2f((warp.nodes[i][j].u * uv_width), (warp.nodes[i][j].v * uv_height)); - glVertex3f(warp.nodes[i][j].x, warp.nodes[i][j].y,0.0); + glVertex3f(warp.nodes[i][j].x, warp.nodes[i][j].y,0.0f); } } glEnd(); @@ -428,19 +428,19 @@ void KX_Dome::GLDrawWarpQuads(void) glColor3f(warp.nodes[i][j].i,warp.nodes[i][j].i,warp.nodes[i][j].i); glTexCoord2f((warp.nodes[i][j].u * uv_width), (warp.nodes[i][j].v * uv_height)); - glVertex3f(warp.nodes[i][j].x,warp.nodes[i][j].y,0.0); + glVertex3f(warp.nodes[i][j].x,warp.nodes[i][j].y,0.0f); glColor3f(warp.nodes[i2][j].i,warp.nodes[i2][j].i,warp.nodes[i2][j].i); glTexCoord2f((warp.nodes[i2][j].u * uv_width), (warp.nodes[i2][j].v * uv_height)); - glVertex3f(warp.nodes[i2][j].x,warp.nodes[i2][j].y,0.0); + glVertex3f(warp.nodes[i2][j].x,warp.nodes[i2][j].y,0.0f); glColor3f(warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i); glTexCoord2f((warp.nodes[i2][j+1].u * uv_width), (warp.nodes[i2][j+1].v * uv_height)); - glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0); + glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0f); glColor3f(warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i); glTexCoord2f((warp.nodes[i2][j+1].u * uv_width), (warp.nodes[i2][j+1].v * uv_height)); - glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0); + glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0f); } } @@ -551,42 +551,42 @@ void KX_Dome::CreateMeshDome180(void) //creating faces for the env mapcube 180deg Dome // Top Face - just a triangle - cubetop[0].verts[0][0] = -M_SQRT2 / 2.0; - cubetop[0].verts[0][1] = 0.0; - cubetop[0].verts[0][2] = 0.5; + cubetop[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f; + cubetop[0].verts[0][1] = 0.0f; + cubetop[0].verts[0][2] = 0.5f; cubetop[0].u[0] = 0.0; cubetop[0].v[0] = uv_ratio; - cubetop[0].verts[1][0] = 0.0; - cubetop[0].verts[1][1] = M_SQRT2 / 2.0; - cubetop[0].verts[1][2] = 0.5; + cubetop[0].verts[1][0] = 0.0f; + cubetop[0].verts[1][1] = (float)M_SQRT2 / 2.0f; + cubetop[0].verts[1][2] = 0.5f; cubetop[0].u[1] = 0.0; cubetop[0].v[1] = 0.0; - cubetop[0].verts[2][0] = M_SQRT2 / 2.0; - cubetop[0].verts[2][1] = 0.0; - cubetop[0].verts[2][2] = 0.5; + cubetop[0].verts[2][0] = (float)M_SQRT2 / 2.0f; + cubetop[0].verts[2][1] = 0.0f; + cubetop[0].verts[2][2] = 0.5f; cubetop[0].u[2] = uv_ratio; cubetop[0].v[2] = 0.0; nfacestop = 1; /* Bottom face - just a triangle */ - cubebottom[0].verts[0][0] = -M_SQRT2 / 2.0; - cubebottom[0].verts[0][1] = 0.0; - cubebottom[0].verts[0][2] = -0.5; + cubebottom[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f; + cubebottom[0].verts[0][1] = 0.0f; + cubebottom[0].verts[0][2] = -0.5f; cubebottom[0].u[0] = uv_ratio; cubebottom[0].v[0] = 0.0; - cubebottom[0].verts[1][0] = M_SQRT2 / 2.0; + cubebottom[0].verts[1][0] = (float)M_SQRT2 / 2.0f; cubebottom[0].verts[1][1] = 0; - cubebottom[0].verts[1][2] = -0.5; + cubebottom[0].verts[1][2] = -0.5f; cubebottom[0].u[1] = 0.0; cubebottom[0].v[1] = uv_ratio; - cubebottom[0].verts[2][0] = 0.0; - cubebottom[0].verts[2][1] = M_SQRT2 / 2.0; - cubebottom[0].verts[2][2] = -0.5; + cubebottom[0].verts[2][0] = 0.0f; + cubebottom[0].verts[2][1] = (float)M_SQRT2 / 2.0f; + cubebottom[0].verts[2][2] = -0.5f; cubebottom[0].u[2] = 0.0; cubebottom[0].v[2] = 0.0; @@ -594,80 +594,80 @@ void KX_Dome::CreateMeshDome180(void) /* Left face - two triangles */ - cubeleft[0].verts[0][0] = -M_SQRT2 / 2.0; - cubeleft[0].verts[0][1] = 0.0; - cubeleft[0].verts[0][2] = -0.5; + cubeleft[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f; + cubeleft[0].verts[0][1] = 0.0f; + cubeleft[0].verts[0][2] = -0.5f; cubeleft[0].u[0] = 0.0; cubeleft[0].v[0] = 0.0; - cubeleft[0].verts[1][0] = 0.0; - cubeleft[0].verts[1][1] = M_SQRT2 / 2.0; - cubeleft[0].verts[1][2] = -0.5; + cubeleft[0].verts[1][0] = 0.0f; + cubeleft[0].verts[1][1] = (float)M_SQRT2 / 2.0f; + cubeleft[0].verts[1][2] = -0.5f; cubeleft[0].u[1] = uv_ratio; cubeleft[0].v[1] = 0.0; - cubeleft[0].verts[2][0] = -M_SQRT2 / 2.0; - cubeleft[0].verts[2][1] = 0.0; - cubeleft[0].verts[2][2] = 0.5; + cubeleft[0].verts[2][0] = (float)(-M_SQRT2) / 2.0f; + cubeleft[0].verts[2][1] = 0.0f; + cubeleft[0].verts[2][2] = 0.5f; cubeleft[0].u[2] = 0.0; cubeleft[0].v[2] = uv_ratio; //second triangle - cubeleft[1].verts[0][0] = -M_SQRT2 / 2.0; - cubeleft[1].verts[0][1] = 0.0; - cubeleft[1].verts[0][2] = 0.5; + cubeleft[1].verts[0][0] = (float)(-M_SQRT2) / 2.0f; + cubeleft[1].verts[0][1] = 0.0f; + cubeleft[1].verts[0][2] = 0.5f; cubeleft[1].u[0] = 0.0; cubeleft[1].v[0] = uv_ratio; - cubeleft[1].verts[1][0] = 0.0; - cubeleft[1].verts[1][1] = M_SQRT2 / 2.0; - cubeleft[1].verts[1][2] = -0.5; + cubeleft[1].verts[1][0] = 0.0f; + cubeleft[1].verts[1][1] = (float)M_SQRT2 / 2.0f; + cubeleft[1].verts[1][2] = -0.5f; cubeleft[1].u[1] = uv_ratio; cubeleft[1].v[1] = 0.0; - cubeleft[1].verts[2][0] = 0.0; - cubeleft[1].verts[2][1] = M_SQRT2 / 2.0; - cubeleft[1].verts[2][2] = 0.5; + cubeleft[1].verts[2][0] = 0.0f; + cubeleft[1].verts[2][1] = (float)M_SQRT2 / 2.0f; + cubeleft[1].verts[2][2] = 0.5f; cubeleft[1].u[2] = uv_ratio; cubeleft[1].v[2] = uv_ratio; nfacesleft = 2; /* Right face - two triangles */ - cuberight[0].verts[0][0] = 0.0; - cuberight[0].verts[0][1] = M_SQRT2 / 2.0; - cuberight[0].verts[0][2] = -0.5; + cuberight[0].verts[0][0] = 0.0f; + cuberight[0].verts[0][1] = (float)M_SQRT2 / 2.0f; + cuberight[0].verts[0][2] = -0.5f; cuberight[0].u[0] = 0.0; cuberight[0].v[0] = 0.0; - cuberight[0].verts[1][0] = M_SQRT2 / 2.0; - cuberight[0].verts[1][1] = 0.0; - cuberight[0].verts[1][2] = -0.5; + cuberight[0].verts[1][0] = (float)M_SQRT2 / 2.0f; + cuberight[0].verts[1][1] = 0.0f; + cuberight[0].verts[1][2] = -0.5f; cuberight[0].u[1] = uv_ratio; cuberight[0].v[1] = 0.0; - cuberight[0].verts[2][0] = M_SQRT2 / 2.0; - cuberight[0].verts[2][1] = 0.0; - cuberight[0].verts[2][2] = 0.5; + cuberight[0].verts[2][0] = (float)M_SQRT2 / 2.0f; + cuberight[0].verts[2][1] = 0.0f; + cuberight[0].verts[2][2] = 0.5f; cuberight[0].u[2] = uv_ratio; cuberight[0].v[2] = uv_ratio; //second triangle - cuberight[1].verts[0][0] = 0.0; - cuberight[1].verts[0][1] = M_SQRT2 / 2.0; - cuberight[1].verts[0][2] = -0.5; + cuberight[1].verts[0][0] = 0.0f; + cuberight[1].verts[0][1] = (float)M_SQRT2 / 2.0f; + cuberight[1].verts[0][2] = -0.5f; cuberight[1].u[0] = 0.0; cuberight[1].v[0] = 0.0; - cuberight[1].verts[1][0] = M_SQRT2 / 2.0; - cuberight[1].verts[1][1] = 0.0; - cuberight[1].verts[1][2] = 0.5; + cuberight[1].verts[1][0] = (float)M_SQRT2 / 2.0f; + cuberight[1].verts[1][1] = 0.0f; + cuberight[1].verts[1][2] = 0.5f; cuberight[1].u[1] = uv_ratio; cuberight[1].v[1] = uv_ratio; - cuberight[1].verts[2][0] = 0.0; - cuberight[1].verts[2][1] = M_SQRT2 / 2.0; - cuberight[1].verts[2][2] = 0.5; + cuberight[1].verts[2][0] = 0.0f; + cuberight[1].verts[2][1] = (float)M_SQRT2 / 2.0f; + cuberight[1].verts[2][2] = 0.5f; cuberight[1].u[2] = 0.0; cuberight[1].v[2] = uv_ratio; @@ -728,10 +728,10 @@ void KX_Dome::CreateMeshDome250(void) float uv_height, uv_base; float verts_height; - float rad_ang = m_angle * MT_PI / 180.0; + float rad_ang = m_angle * MT_PI / 180.0f; float uv_ratio = (float)(m_buffersize-1) / m_imagesize; - m_radangle = m_angle * M_PI/180.0;//calculates the radians angle, used for flattening + m_radangle = m_angle * (float)M_PI/180.0f;//calculates the radians angle, used for flattening /* * verts_height is the exactly needed height of the cube faces (not always 1.0). * When we want some horizontal information (e.g. for horizontal 220deg domes) we don't need to create and tessellate the whole cube. @@ -746,207 +746,207 @@ void KX_Dome::CreateMeshDome250(void) * Once we take the tangent of that angle, you have the verts coordinate corresponding to the verts on the side faces. * Then we need to multiply it by sqrt(2.0) to get the coordinate of the verts on the diagonal of the original cube. */ - verts_height = tanf((rad_ang / 2.0f) - (float)(MT_PI / 2.0)) * (float)M_SQRT2; + verts_height = tanf((rad_ang / 2.0f) - (MT_PI / 2.0f)) * (float)M_SQRT2; uv_height = uv_ratio * ( (verts_height / 2.0f) + 0.5f); - uv_base = uv_ratio * (1.0 - ((verts_height / 2.0f) + 0.5f)); + uv_base = uv_ratio * (1.0f - ((verts_height / 2.0f) + 0.5f)); //creating faces for the env mapcube 180deg Dome // Front Face - 2 triangles - cubefront[0].verts[0][0] =-1.0; - cubefront[0].verts[0][1] = 1.0; - cubefront[0].verts[0][2] =-1.0; + cubefront[0].verts[0][0] =-1.0f; + cubefront[0].verts[0][1] = 1.0f; + cubefront[0].verts[0][2] =-1.0f; cubefront[0].u[0] = 0.0; cubefront[0].v[0] = 0.0; - cubefront[0].verts[1][0] = 1.0; - cubefront[0].verts[1][1] = 1.0; - cubefront[0].verts[1][2] = 1.0; + cubefront[0].verts[1][0] = 1.0f; + cubefront[0].verts[1][1] = 1.0f; + cubefront[0].verts[1][2] = 1.0f; cubefront[0].u[1] = uv_ratio; cubefront[0].v[1] = uv_ratio; - cubefront[0].verts[2][0] =-1.0; - cubefront[0].verts[2][1] = 1.0; - cubefront[0].verts[2][2] = 1.0; + cubefront[0].verts[2][0] =-1.0f; + cubefront[0].verts[2][1] = 1.0f; + cubefront[0].verts[2][2] = 1.0f; cubefront[0].u[2] = 0.0; cubefront[0].v[2] = uv_ratio; //second triangle - cubefront[1].verts[0][0] = 1.0; - cubefront[1].verts[0][1] = 1.0; - cubefront[1].verts[0][2] = 1.0; + cubefront[1].verts[0][0] = 1.0f; + cubefront[1].verts[0][1] = 1.0f; + cubefront[1].verts[0][2] = 1.0f; cubefront[1].u[0] = uv_ratio; cubefront[1].v[0] = uv_ratio; - cubefront[1].verts[1][0] =-1.0; - cubefront[1].verts[1][1] = 1.0; - cubefront[1].verts[1][2] =-1.0; + cubefront[1].verts[1][0] =-1.0f; + cubefront[1].verts[1][1] = 1.0f; + cubefront[1].verts[1][2] =-1.0f; cubefront[1].u[1] = 0.0; cubefront[1].v[1] = 0.0; - cubefront[1].verts[2][0] = 1.0; - cubefront[1].verts[2][1] = 1.0; - cubefront[1].verts[2][2] =-1.0; + cubefront[1].verts[2][0] = 1.0f; + cubefront[1].verts[2][1] = 1.0f; + cubefront[1].verts[2][2] =-1.0f; cubefront[1].u[2] = uv_ratio; cubefront[1].v[2] = 0.0; nfacesfront = 2; // Left Face - 2 triangles - cubeleft[0].verts[0][0] =-1.0; - cubeleft[0].verts[0][1] = 1.0; - cubeleft[0].verts[0][2] =-1.0; + cubeleft[0].verts[0][0] =-1.0f; + cubeleft[0].verts[0][1] = 1.0f; + cubeleft[0].verts[0][2] =-1.0f; cubeleft[0].u[0] = uv_ratio; cubeleft[0].v[0] = 0.0; - cubeleft[0].verts[1][0] =-1.0; + cubeleft[0].verts[1][0] =-1.0f; cubeleft[0].verts[1][1] =-verts_height; - cubeleft[0].verts[1][2] = 1.0; + cubeleft[0].verts[1][2] = 1.0f; cubeleft[0].u[1] = uv_base; cubeleft[0].v[1] = uv_ratio; - cubeleft[0].verts[2][0] =-1.0; + cubeleft[0].verts[2][0] =-1.0f; cubeleft[0].verts[2][1] =-verts_height; - cubeleft[0].verts[2][2] =-1.0; + cubeleft[0].verts[2][2] =-1.0f; cubeleft[0].u[2] = uv_base; cubeleft[0].v[2] = 0.0; //second triangle - cubeleft[1].verts[0][0] =-1.0; + cubeleft[1].verts[0][0] =-1.0f; cubeleft[1].verts[0][1] =-verts_height; - cubeleft[1].verts[0][2] = 1.0; + cubeleft[1].verts[0][2] = 1.0f; cubeleft[1].u[0] = uv_base; cubeleft[1].v[0] = uv_ratio; - cubeleft[1].verts[1][0] =-1.0; - cubeleft[1].verts[1][1] = 1.0; - cubeleft[1].verts[1][2] =-1.0; + cubeleft[1].verts[1][0] =-1.0f; + cubeleft[1].verts[1][1] = 1.0f; + cubeleft[1].verts[1][2] =-1.0f; cubeleft[1].u[1] = uv_ratio; cubeleft[1].v[1] = 0.0; - cubeleft[1].verts[2][0] =-1.0; - cubeleft[1].verts[2][1] = 1.0; - cubeleft[1].verts[2][2] = 1.0; + cubeleft[1].verts[2][0] =-1.0f; + cubeleft[1].verts[2][1] = 1.0f; + cubeleft[1].verts[2][2] = 1.0f; cubeleft[1].u[2] = uv_ratio; cubeleft[1].v[2] = uv_ratio; nfacesleft = 2; // right Face - 2 triangles - cuberight[0].verts[0][0] = 1.0; - cuberight[0].verts[0][1] = 1.0; - cuberight[0].verts[0][2] = 1.0; + cuberight[0].verts[0][0] = 1.0f; + cuberight[0].verts[0][1] = 1.0f; + cuberight[0].verts[0][2] = 1.0f; cuberight[0].u[0] = 0.0; cuberight[0].v[0] = uv_ratio; - cuberight[0].verts[1][0] = 1.0; + cuberight[0].verts[1][0] = 1.0f; cuberight[0].verts[1][1] =-verts_height; - cuberight[0].verts[1][2] =-1.0; + cuberight[0].verts[1][2] =-1.0f; cuberight[0].u[1] = uv_height; cuberight[0].v[1] = 0.0; - cuberight[0].verts[2][0] = 1.0; + cuberight[0].verts[2][0] = 1.0f; cuberight[0].verts[2][1] =-verts_height; - cuberight[0].verts[2][2] = 1.0; + cuberight[0].verts[2][2] = 1.0f; cuberight[0].u[2] = uv_height; cuberight[0].v[2] = uv_ratio; //second triangle - cuberight[1].verts[0][0] = 1.0; + cuberight[1].verts[0][0] = 1.0f; cuberight[1].verts[0][1] =-verts_height; - cuberight[1].verts[0][2] =-1.0; + cuberight[1].verts[0][2] =-1.0f; cuberight[1].u[0] = uv_height; cuberight[1].v[0] = 0.0; - cuberight[1].verts[1][0] = 1.0; - cuberight[1].verts[1][1] = 1.0; - cuberight[1].verts[1][2] = 1.0; + cuberight[1].verts[1][0] = 1.0f; + cuberight[1].verts[1][1] = 1.0f; + cuberight[1].verts[1][2] = 1.0f; cuberight[1].u[1] = 0.0; cuberight[1].v[1] = uv_ratio; - cuberight[1].verts[2][0] = 1.0; - cuberight[1].verts[2][1] = 1.0; - cuberight[1].verts[2][2] =-1.0; + cuberight[1].verts[2][0] = 1.0f; + cuberight[1].verts[2][1] = 1.0f; + cuberight[1].verts[2][2] =-1.0f; cuberight[1].u[2] = 0.0; cuberight[1].v[2] = 0.0; nfacesright = 2; // top Face - 2 triangles - cubetop[0].verts[0][0] =-1.0; - cubetop[0].verts[0][1] = 1.0; - cubetop[0].verts[0][2] = 1.0; + cubetop[0].verts[0][0] =-1.0f; + cubetop[0].verts[0][1] = 1.0f; + cubetop[0].verts[0][2] = 1.0f; cubetop[0].u[0] = 0.0; cubetop[0].v[0] = 0.0; - cubetop[0].verts[1][0] = 1.0; + cubetop[0].verts[1][0] = 1.0f; cubetop[0].verts[1][1] =-verts_height; - cubetop[0].verts[1][2] = 1.0; + cubetop[0].verts[1][2] = 1.0f; cubetop[0].u[1] = uv_ratio; cubetop[0].v[1] = uv_height; - cubetop[0].verts[2][0] =-1.0; + cubetop[0].verts[2][0] =-1.0f; cubetop[0].verts[2][1] =-verts_height; - cubetop[0].verts[2][2] = 1.0; + cubetop[0].verts[2][2] = 1.0f; cubetop[0].u[2] = 0.0; cubetop[0].v[2] = uv_height; //second triangle - cubetop[1].verts[0][0] = 1.0; + cubetop[1].verts[0][0] = 1.0f; cubetop[1].verts[0][1] =-verts_height; - cubetop[1].verts[0][2] = 1.0; + cubetop[1].verts[0][2] = 1.0f; cubetop[1].u[0] = uv_ratio; cubetop[1].v[0] = uv_height; - cubetop[1].verts[1][0] =-1.0; - cubetop[1].verts[1][1] = 1.0; - cubetop[1].verts[1][2] = 1.0; + cubetop[1].verts[1][0] =-1.0f; + cubetop[1].verts[1][1] = 1.0f; + cubetop[1].verts[1][2] = 1.0f; cubetop[1].u[1] = 0.0; cubetop[1].v[1] = 0.0; - cubetop[1].verts[2][0] = 1.0; - cubetop[1].verts[2][1] = 1.0; - cubetop[1].verts[2][2] = 1.0; + cubetop[1].verts[2][0] = 1.0f; + cubetop[1].verts[2][1] = 1.0f; + cubetop[1].verts[2][2] = 1.0f; cubetop[1].u[2] = uv_ratio; cubetop[1].v[2] = 0.0; nfacestop = 2; // bottom Face - 2 triangles - cubebottom[0].verts[0][0] =-1.0; + cubebottom[0].verts[0][0] =-1.0f; cubebottom[0].verts[0][1] =-verts_height; - cubebottom[0].verts[0][2] =-1.0; + cubebottom[0].verts[0][2] =-1.0f; cubebottom[0].u[0] = 0.0; cubebottom[0].v[0] = uv_base; - cubebottom[0].verts[1][0] = 1.0; - cubebottom[0].verts[1][1] = 1.0; - cubebottom[0].verts[1][2] =-1.0; + cubebottom[0].verts[1][0] = 1.0f; + cubebottom[0].verts[1][1] = 1.0f; + cubebottom[0].verts[1][2] =-1.0f; cubebottom[0].u[1] = uv_ratio; cubebottom[0].v[1] = uv_ratio; - cubebottom[0].verts[2][0] =-1.0; - cubebottom[0].verts[2][1] = 1.0; - cubebottom[0].verts[2][2] =-1.0; + cubebottom[0].verts[2][0] =-1.0f; + cubebottom[0].verts[2][1] = 1.0f; + cubebottom[0].verts[2][2] =-1.0f; cubebottom[0].u[2] = 0.0; cubebottom[0].v[2] = uv_ratio; //second triangle - cubebottom[1].verts[0][0] = 1.0; - cubebottom[1].verts[0][1] = 1.0; - cubebottom[1].verts[0][2] =-1.0; + cubebottom[1].verts[0][0] = 1.0f; + cubebottom[1].verts[0][1] = 1.0f; + cubebottom[1].verts[0][2] =-1.0f; cubebottom[1].u[0] = uv_ratio; cubebottom[1].v[0] = uv_ratio; - cubebottom[1].verts[1][0] =-1.0; + cubebottom[1].verts[1][0] =-1.0f; cubebottom[1].verts[1][1] =-verts_height; - cubebottom[1].verts[1][2] =-1.0; + cubebottom[1].verts[1][2] =-1.0f; cubebottom[1].u[1] = 0.0; cubebottom[1].v[1] = uv_base; - cubebottom[1].verts[2][0] = 1.0; + cubebottom[1].verts[2][0] = 1.0f; cubebottom[1].verts[2][1] =-verts_height; - cubebottom[1].verts[2][2] =-1.0; + cubebottom[1].verts[2][2] =-1.0f; cubebottom[1].u[2] = uv_ratio; cubebottom[1].v[2] = uv_base; @@ -1012,80 +1012,80 @@ void KX_Dome::CreateMeshPanorama(void) float uv_ratio = (float)(m_buffersize-1) / m_imagesize; /* Top face - two triangles */ - cubetop[0].verts[0][0] = -M_SQRT2; - cubetop[0].verts[0][1] = 0.0; - cubetop[0].verts[0][2] = 1.0; + cubetop[0].verts[0][0] = (float)(-M_SQRT2); + cubetop[0].verts[0][1] = 0.0f; + cubetop[0].verts[0][2] = 1.0f; cubetop[0].u[0] = 0.0; cubetop[0].v[0] = uv_ratio; - cubetop[0].verts[1][0] = 0.0; - cubetop[0].verts[1][1] = M_SQRT2; - cubetop[0].verts[1][2] = 1.0; + cubetop[0].verts[1][0] = 0.0f; + cubetop[0].verts[1][1] = (float)M_SQRT2; + cubetop[0].verts[1][2] = 1.0f; cubetop[0].u[1] = 0.0; cubetop[0].v[1] = 0.0; //second triangle - cubetop[0].verts[2][0] = M_SQRT2; - cubetop[0].verts[2][1] = 0.0; - cubetop[0].verts[2][2] = 1.0; + cubetop[0].verts[2][0] = (float)M_SQRT2; + cubetop[0].verts[2][1] = 0.0f; + cubetop[0].verts[2][2] = 1.0f; cubetop[0].u[2] = uv_ratio; cubetop[0].v[2] = 0.0; - cubetop[1].verts[0][0] = M_SQRT2; - cubetop[1].verts[0][1] = 0.0; - cubetop[1].verts[0][2] = 1.0; + cubetop[1].verts[0][0] = (float)M_SQRT2; + cubetop[1].verts[0][1] = 0.0f; + cubetop[1].verts[0][2] = 1.0f; cubetop[1].u[0] = uv_ratio; cubetop[1].v[0] = 0.0; - cubetop[1].verts[1][0] = 0.0; - cubetop[1].verts[1][1] = -M_SQRT2; - cubetop[1].verts[1][2] = 1.0; + cubetop[1].verts[1][0] = 0.0f; + cubetop[1].verts[1][1] = (float)(-M_SQRT2); + cubetop[1].verts[1][2] = 1.0f; cubetop[1].u[1] = uv_ratio; cubetop[1].v[1] = uv_ratio; - cubetop[1].verts[2][0] = -M_SQRT2; - cubetop[1].verts[2][1] = 0.0; - cubetop[1].verts[2][2] = 1.0; + cubetop[1].verts[2][0] = (float)(-M_SQRT2); + cubetop[1].verts[2][1] = 0.0f; + cubetop[1].verts[2][2] = 1.0f; cubetop[1].u[2] = 0.0; cubetop[1].v[2] = uv_ratio; nfacestop = 2; /* Bottom face - two triangles */ - cubebottom[0].verts[0][0] = -M_SQRT2; - cubebottom[0].verts[0][1] = 0.0; - cubebottom[0].verts[0][2] = -1.0; + cubebottom[0].verts[0][0] = (float)(-M_SQRT2); + cubebottom[0].verts[0][1] = 0.0f; + cubebottom[0].verts[0][2] = -1.0f; cubebottom[0].u[0] = uv_ratio; cubebottom[0].v[0] = 0.0; - cubebottom[0].verts[1][0] = M_SQRT2; - cubebottom[0].verts[1][1] = 0.0; - cubebottom[0].verts[1][2] = -1.0; + cubebottom[0].verts[1][0] = (float)M_SQRT2; + cubebottom[0].verts[1][1] = 0.0f; + cubebottom[0].verts[1][2] = -1.0f; cubebottom[0].u[1] = 0.0; cubebottom[0].v[1] = uv_ratio; - cubebottom[0].verts[2][0] = 0.0; - cubebottom[0].verts[2][1] = M_SQRT2; - cubebottom[0].verts[2][2] = -1.0; + cubebottom[0].verts[2][0] = 0.0f; + cubebottom[0].verts[2][1] = (float)M_SQRT2; + cubebottom[0].verts[2][2] = -1.0f; cubebottom[0].u[2] = 0.0; cubebottom[0].v[2] = 0.0; //second triangle - cubebottom[1].verts[0][0] = M_SQRT2; - cubebottom[1].verts[0][1] = 0.0; - cubebottom[1].verts[0][2] = -1.0; + cubebottom[1].verts[0][0] = (float)M_SQRT2; + cubebottom[1].verts[0][1] = 0.0f; + cubebottom[1].verts[0][2] = -1.0f; cubebottom[1].u[0] = 0.0; cubebottom[1].v[0] = uv_ratio; - cubebottom[1].verts[1][0] = -M_SQRT2; - cubebottom[1].verts[1][1] = 0.0; - cubebottom[1].verts[1][2] = -1.0; + cubebottom[1].verts[1][0] = (float)(-M_SQRT2); + cubebottom[1].verts[1][1] = 0.0f; + cubebottom[1].verts[1][2] = -1.0f; cubebottom[1].u[1] = uv_ratio; cubebottom[1].v[1] = 0.0; - cubebottom[1].verts[2][0] = 0.0; - cubebottom[1].verts[2][1] = -M_SQRT2; - cubebottom[1].verts[2][2] = -1.0; + cubebottom[1].verts[2][0] = 0.0f; + cubebottom[1].verts[2][1] = (float)(-M_SQRT2); + cubebottom[1].verts[2][2] = -1.0f; cubebottom[1].u[2] = uv_ratio; cubebottom[1].v[2] = uv_ratio; @@ -1093,40 +1093,40 @@ void KX_Dome::CreateMeshPanorama(void) /* Left Back (135deg) face - two triangles */ - cubeleftback[0].verts[0][0] = 0; - cubeleftback[0].verts[0][1] = -M_SQRT2; - cubeleftback[0].verts[0][2] = -1.0; - cubeleftback[0].u[0] = 0; - cubeleftback[0].v[0] = 0; + cubeleftback[0].verts[0][0] = 0.0f; + cubeleftback[0].verts[0][1] = (float)(-M_SQRT2); + cubeleftback[0].verts[0][2] = -1.0f; + cubeleftback[0].u[0] = 0.0; + cubeleftback[0].v[0] = 0.0; - cubeleftback[0].verts[1][0] = -M_SQRT2; - cubeleftback[0].verts[1][1] = 0; - cubeleftback[0].verts[1][2] = -1.0; + cubeleftback[0].verts[1][0] = (float)(-M_SQRT2); + cubeleftback[0].verts[1][1] = 0.0f; + cubeleftback[0].verts[1][2] = -1.0f; cubeleftback[0].u[1] = uv_ratio; - cubeleftback[0].v[1] = 0; + cubeleftback[0].v[1] = 0.0; - cubeleftback[0].verts[2][0] = 0; - cubeleftback[0].verts[2][1] = -M_SQRT2; - cubeleftback[0].verts[2][2] = 1.0; - cubeleftback[0].u[2] = 0; + cubeleftback[0].verts[2][0] = 0.0f; + cubeleftback[0].verts[2][1] = (float)(-M_SQRT2); + cubeleftback[0].verts[2][2] = 1.0f; + cubeleftback[0].u[2] = 0.0; cubeleftback[0].v[2] = uv_ratio; //second triangle - cubeleftback[1].verts[0][0] = 0; - cubeleftback[1].verts[0][1] = -M_SQRT2; - cubeleftback[1].verts[0][2] = 1.0; - cubeleftback[1].u[0] = 0; + cubeleftback[1].verts[0][0] = 0.0f; + cubeleftback[1].verts[0][1] = (float)(-M_SQRT2); + cubeleftback[1].verts[0][2] = 1.0f; + cubeleftback[1].u[0] = 0.0; cubeleftback[1].v[0] = uv_ratio; - cubeleftback[1].verts[1][0] = -M_SQRT2; - cubeleftback[1].verts[1][1] = 0; - cubeleftback[1].verts[1][2] = -1.0; + cubeleftback[1].verts[1][0] = (float)(-M_SQRT2); + cubeleftback[1].verts[1][1] = 0.0f; + cubeleftback[1].verts[1][2] = -1.0f; cubeleftback[1].u[1] = uv_ratio; - cubeleftback[1].v[1] = 0; + cubeleftback[1].v[1] = 0.0; - cubeleftback[1].verts[2][0] = -M_SQRT2; - cubeleftback[1].verts[2][1] = 0; - cubeleftback[1].verts[2][2] = 1.0; + cubeleftback[1].verts[2][0] = (float)(-M_SQRT2); + cubeleftback[1].verts[2][1] = 0.0f; + cubeleftback[1].verts[2][2] = 1.0f; cubeleftback[1].u[2] = uv_ratio; cubeleftback[1].v[2] = uv_ratio; @@ -1134,121 +1134,121 @@ void KX_Dome::CreateMeshPanorama(void) /* Left face - two triangles */ - cubeleft[0].verts[0][0] = -M_SQRT2; - cubeleft[0].verts[0][1] = 0; - cubeleft[0].verts[0][2] = -1.0; - cubeleft[0].u[0] = 0; - cubeleft[0].v[0] = 0; - - cubeleft[0].verts[1][0] = 0; - cubeleft[0].verts[1][1] = M_SQRT2; - cubeleft[0].verts[1][2] = -1.0; + cubeleft[0].verts[0][0] = (float)(-M_SQRT2); + cubeleft[0].verts[0][1] = 0.0f; + cubeleft[0].verts[0][2] = -1.0f; + cubeleft[0].u[0] = 0.0; + cubeleft[0].v[0] = 0.0; + + cubeleft[0].verts[1][0] = 0.0f; + cubeleft[0].verts[1][1] = (float)M_SQRT2; + cubeleft[0].verts[1][2] = -1.0f; cubeleft[0].u[1] = uv_ratio; - cubeleft[0].v[1] = 0; + cubeleft[0].v[1] = 0.0; - cubeleft[0].verts[2][0] = -M_SQRT2; - cubeleft[0].verts[2][1] = 0; - cubeleft[0].verts[2][2] = 1.0; - cubeleft[0].u[2] = 0; + cubeleft[0].verts[2][0] = (float)(-M_SQRT2); + cubeleft[0].verts[2][1] = 0.0f; + cubeleft[0].verts[2][2] = 1.0f; + cubeleft[0].u[2] = 0.0; cubeleft[0].v[2] = uv_ratio; //second triangle - cubeleft[1].verts[0][0] = -M_SQRT2; - cubeleft[1].verts[0][1] = 0; - cubeleft[1].verts[0][2] = 1.0; - cubeleft[1].u[0] = 0; + cubeleft[1].verts[0][0] = (float)(-M_SQRT2); + cubeleft[1].verts[0][1] = 0.0f; + cubeleft[1].verts[0][2] = 1.0f; + cubeleft[1].u[0] = 0.0; cubeleft[1].v[0] = uv_ratio; - cubeleft[1].verts[1][0] = 0; - cubeleft[1].verts[1][1] = M_SQRT2; - cubeleft[1].verts[1][2] = -1.0; + cubeleft[1].verts[1][0] = 0.0f; + cubeleft[1].verts[1][1] = (float)M_SQRT2; + cubeleft[1].verts[1][2] = -1.0f; cubeleft[1].u[1] = uv_ratio; - cubeleft[1].v[1] = 0; + cubeleft[1].v[1] = 0.0; - cubeleft[1].verts[2][0] = 0; - cubeleft[1].verts[2][1] = M_SQRT2; - cubeleft[1].verts[2][2] = 1.0; + cubeleft[1].verts[2][0] = 0.0f; + cubeleft[1].verts[2][1] = (float)M_SQRT2; + cubeleft[1].verts[2][2] = 1.0f; cubeleft[1].u[2] = uv_ratio; cubeleft[1].v[2] = uv_ratio; nfacesleft = 2; /* Right face - two triangles */ - cuberight[0].verts[0][0] = 0; - cuberight[0].verts[0][1] = M_SQRT2; - cuberight[0].verts[0][2] = -1.0; - cuberight[0].u[0] = 0; - cuberight[0].v[0] = 0; - - cuberight[0].verts[1][0] = M_SQRT2; - cuberight[0].verts[1][1] = 0; - cuberight[0].verts[1][2] = -1.0; + cuberight[0].verts[0][0] = 0.0f; + cuberight[0].verts[0][1] = (float)M_SQRT2; + cuberight[0].verts[0][2] = -1.0f; + cuberight[0].u[0] = 0.0; + cuberight[0].v[0] = 0.0; + + cuberight[0].verts[1][0] = (float)M_SQRT2; + cuberight[0].verts[1][1] = 0.0f; + cuberight[0].verts[1][2] = -1.0f; cuberight[0].u[1] = uv_ratio; - cuberight[0].v[1] = 0; + cuberight[0].v[1] = 0.0; - cuberight[0].verts[2][0] = M_SQRT2; - cuberight[0].verts[2][1] = 0; - cuberight[0].verts[2][2] = 1.0; + cuberight[0].verts[2][0] = (float)M_SQRT2; + cuberight[0].verts[2][1] = 0.0f; + cuberight[0].verts[2][2] = 1.0f; cuberight[0].u[2] = uv_ratio; cuberight[0].v[2] = uv_ratio; //second triangle - cuberight[1].verts[0][0] = 0; - cuberight[1].verts[0][1] = M_SQRT2; - cuberight[1].verts[0][2] = -1.0; - cuberight[1].u[0] = 0; - cuberight[1].v[0] = 0; - - cuberight[1].verts[1][0] = M_SQRT2; - cuberight[1].verts[1][1] = 0; - cuberight[1].verts[1][2] = 1.0; + cuberight[1].verts[0][0] = 0.0f; + cuberight[1].verts[0][1] = (float)M_SQRT2; + cuberight[1].verts[0][2] = -1.0f; + cuberight[1].u[0] = 0.0; + cuberight[1].v[0] = 0.0; + + cuberight[1].verts[1][0] = (float)M_SQRT2; + cuberight[1].verts[1][1] = 0.0f; + cuberight[1].verts[1][2] = 1.0f; cuberight[1].u[1] = uv_ratio; cuberight[1].v[1] = uv_ratio; - cuberight[1].verts[2][0] = 0; - cuberight[1].verts[2][1] = M_SQRT2; - cuberight[1].verts[2][2] = 1.0; - cuberight[1].u[2] = 0; + cuberight[1].verts[2][0] = 0.0f; + cuberight[1].verts[2][1] = (float)M_SQRT2; + cuberight[1].verts[2][2] = 1.0f; + cuberight[1].u[2] = 0.0f; cuberight[1].v[2] = uv_ratio; nfacesright = 2; /* Right Back (-135deg) face - two triangles */ - cuberightback[0].verts[0][0] = M_SQRT2; - cuberightback[0].verts[0][1] = 0; - cuberightback[0].verts[0][2] = -1.0; - cuberightback[0].u[0] = 0; - cuberightback[0].v[0] = 0; - - cuberightback[0].verts[1][0] = 0; - cuberightback[0].verts[1][1] = -M_SQRT2; - cuberightback[0].verts[1][2] = -1.0; + cuberightback[0].verts[0][0] = (float)M_SQRT2; + cuberightback[0].verts[0][1] = 0.0f; + cuberightback[0].verts[0][2] = -1.0f; + cuberightback[0].u[0] = 0.0; + cuberightback[0].v[0] = 0.0; + + cuberightback[0].verts[1][0] = 0.0f; + cuberightback[0].verts[1][1] = (float)(-M_SQRT2); + cuberightback[0].verts[1][2] = -1.0f; cuberightback[0].u[1] = uv_ratio; - cuberightback[0].v[1] = 0; + cuberightback[0].v[1] = 0.0; - cuberightback[0].verts[2][0] = 0; - cuberightback[0].verts[2][1] = -M_SQRT2; - cuberightback[0].verts[2][2] = 1.0; + cuberightback[0].verts[2][0] = 0.0f; + cuberightback[0].verts[2][1] = (float)(-M_SQRT2); + cuberightback[0].verts[2][2] = 1.0f; cuberightback[0].u[2] = uv_ratio; cuberightback[0].v[2] = uv_ratio; //second triangle - cuberightback[1].verts[0][0] = M_SQRT2; - cuberightback[1].verts[0][1] = 0; - cuberightback[1].verts[0][2] = -1.0; - cuberightback[1].u[0] = 0; - cuberightback[1].v[0] = 0; - - cuberightback[1].verts[1][0] = 0; - cuberightback[1].verts[1][1] = -M_SQRT2; - cuberightback[1].verts[1][2] = 1.0; + cuberightback[1].verts[0][0] = (float)M_SQRT2; + cuberightback[1].verts[0][1] = 0.0f; + cuberightback[1].verts[0][2] = -1.0f; + cuberightback[1].u[0] = 0.0; + cuberightback[1].v[0] = 0.0; + + cuberightback[1].verts[1][0] = 0.0f; + cuberightback[1].verts[1][1] = (float)(-M_SQRT2); + cuberightback[1].verts[1][2] = 1.0f; cuberightback[1].u[1] = uv_ratio; cuberightback[1].v[1] = uv_ratio; - cuberightback[1].verts[2][0] = M_SQRT2; - cuberightback[1].verts[2][1] = 0; - cuberightback[1].verts[2][2] = 1.0; - cuberightback[1].u[2] = 0; + cuberightback[1].verts[2][0] = (float)M_SQRT2; + cuberightback[1].verts[2][1] = 0.0f; + cuberightback[1].verts[2][2] = 1.0f; + cuberightback[1].u[2] = 0.0; cuberightback[1].v[2] = uv_ratio; nfacesrightback = 2; @@ -1328,13 +1328,13 @@ void KX_Dome::FlattenDome(MT_Vector3 verts[3]) phi = atan2(verts[i][2], verts[i][0]); verts[i][0] = r * cos(phi); - verts[i][1] = 0; + verts[i][1] = 0.0f; verts[i][2] = r * sin(phi); if (r > 1.0) { //round the border verts[i][0] = cos(phi); - verts[i][1] = -3.0; + verts[i][1] = -3.0f; verts[i][2] = sin(phi); } } @@ -1355,7 +1355,7 @@ void KX_Dome::FlattenPanorama(MT_Vector3 verts[3]) edge=true; verts[i][0] = phi / MT_PI; - verts[i][1] = 0; + verts[i][1] = 0.0f; theta = asin(verts[i][2]); verts[i][2] = theta / MT_PI; @@ -1364,15 +1364,15 @@ void KX_Dome::FlattenPanorama(MT_Vector3 verts[3]) bool right=false; for (i=0;i<3;i++) { - if (fmod(verts[i][0],1.0) > 0.0) { + if (fmodf(verts[i][0],1.0f) > 0.0f) { right=true; break; } } if (right) { for (i=0;i<3;i++) { - if (verts[i][0] < 0.0) - verts[i][0] *= -1.0; + if (verts[i][0] < 0.0f) + verts[i][0] *= -1.0f; } } } @@ -1438,8 +1438,8 @@ void KX_Dome::CalculateFrustum(KX_Camera *cam) // manually creating a 90deg Field of View Frustum // the original formula: - top = tan(fov*3.14159/360.0) * near [for fov in degrees] - fov*0.5 = arctan ((top-bottom)*0.5 / near) [for fov in radians] + top = tan(fov*3.14159f/30.0f)) * near [for fov in degrees] + fov*0.5f = arctan ((top-bottom)*0.5f / near) [for fov in radians] bottom = -top left = aspect * bottom right = aspect * top @@ -1447,7 +1447,7 @@ void KX_Dome::CalculateFrustum(KX_Camera *cam) // the equivalent GLU call is: glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(90.0,1.0,cam->GetCameraNear(),cam->GetCameraFar()); + gluPerspective(90.0f,1.0f,cam->GetCameraNear(),cam->GetCameraFar()); #endif RAS_FrameFrustum m_frustrum; //90 deg. Frustum @@ -1455,7 +1455,7 @@ void KX_Dome::CalculateFrustum(KX_Camera *cam) m_frustrum.camnear = cam->GetCameraNear(); m_frustrum.camfar = cam->GetCameraFar(); -// float top = tan(90.0*MT_PI/360.0) * m_frustrum.camnear; +// float top = tan(90.0f*MT_PI/360.0f) * m_frustrum.camnear; float top = m_frustrum.camnear; // for deg = 90deg, tan = 1 m_frustrum.x1 = -top; @@ -1476,112 +1476,112 @@ void KX_Dome::CalculateCameraOrientation() * Uses 6 cameras for angles up to 360deg */ int i; - float deg45 = MT_PI / 4; - MT_Scalar c = cos(deg45); - MT_Scalar s = sin(deg45); + float deg45 = MT_PI / 4.0f; + MT_Scalar c = cosf(deg45); + MT_Scalar s = sinf(deg45); if (m_angle <= 180 && (m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR)) { m_locRot[0] = MT_Matrix3x3( // 90deg - Top - c, -s, 0.0, - 0.0,0.0, -1.0, - s, c, 0.0); + c, -s, 0.0f, + 0.0f,0.0f, -1.0f, + s, c, 0.0f); m_locRot[1] = MT_Matrix3x3( // 90deg - Bottom - -s, c, 0.0, - 0.0,0.0, 1.0, - s, c, 0.0); + -s, c, 0.0f, + 0.0f,0.0f, 1.0f, + s, c, 0.0f); m_locRot[2] = MT_Matrix3x3( // 45deg - Left - c, 0.0, s, - 0, 1.0, 0.0, - -s, 0.0, c); + c, 0.0f, s, + 0, 1.0f, 0.0f, + -s, 0.0f, c); m_locRot[3] = MT_Matrix3x3( // 45deg - Right - c, 0.0, -s, - 0.0, 1.0, 0.0, - s, 0.0, c); + c, 0.0f, -s, + 0.0f, 1.0f, 0.0f, + s, 0.0f, c); } else if (m_mode == DOME_ENVMAP || (m_angle > 180 && (m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR))) { m_locRot[0] = MT_Matrix3x3( // 90deg - Top - 1.0, 0.0, 0.0, - 0.0, 0.0,-1.0, - 0.0, 1.0, 0.0); + 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f,-1.0f, + 0.0f, 1.0f, 0.0f); m_locRot[1] = MT_Matrix3x3( // 90deg - Bottom - 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - 0.0,-1.0, 0.0); + 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + 0.0f,-1.0f, 0.0f); m_locRot[2] = MT_Matrix3x3( // -90deg - Left - 0.0, 0.0, 1.0, - 0.0, 1.0, 0.0, - -1.0, 0.0, 0.0); + 0.0f, 0.0f, 1.0f, + 0.0f, 1.0f, 0.0f, + -1.0f, 0.0f, 0.0f); m_locRot[3] = MT_Matrix3x3( // 90deg - Right - 0.0, 0.0,-1.0, - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0); + 0.0f, 0.0f,-1.0f, + 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f); m_locRot[4] = MT_Matrix3x3( // 0deg - Front - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0); + 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f); m_locRot[5] = MT_Matrix3x3( // 180deg - Back - USED for ENVMAP only - -1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0,-1.0); + -1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f,-1.0f); } else if (m_mode == DOME_PANORAM_SPH) { m_locRot[0] = MT_Matrix3x3( // Top - c, s, 0.0, - 0.0,0.0, -1.0, - -s, c, 0.0); + c, s, 0.0f, + 0.0f,0.0f, -1.0f, + -s, c, 0.0f); m_locRot[1] = MT_Matrix3x3( // Bottom - c, s, 0.0, - 0.0, 0.0, 1.0, - s, -c, 0.0); + c, s, 0.0f, + 0.0f, 0.0f, 1.0f, + s, -c, 0.0f); m_locRot[2] = MT_Matrix3x3( // 45deg - Left - -s, 0.0, c, - 0, 1.0, 0.0, - -c, 0.0, -s); + -s, 0.0f, c, + 0, 1.0f, 0.0f, + -c, 0.0f, -s); m_locRot[3] = MT_Matrix3x3( // 45deg - Right - c, 0.0, s, - 0, 1.0, 0.0, - -s, 0.0, c); + c, 0.0f, s, + 0, 1.0f, 0.0f, + -s, 0.0f, c); m_locRot[4] = MT_Matrix3x3( // 135deg - LeftBack - -s, 0.0, -c, - 0.0, 1.0, 0.0, - c, 0.0, -s); + -s, 0.0f, -c, + 0.0f, 1.0f, 0.0f, + c, 0.0f, -s); m_locRot[5] = MT_Matrix3x3( // 135deg - RightBack - c, 0.0, -s, - 0.0, 1.0, 0.0, - s, 0.0, c); + c, 0.0f, -s, + 0.0f, 1.0f, 0.0f, + s, 0.0f, c); } // rotating the camera in horizontal axis if (m_tilt) { float tiltdeg = ((m_tilt % 360) * 2 * MT_PI) / 360; - c = cos(tiltdeg); - s = sin(tiltdeg); + c = cosf(tiltdeg); + s = sinf(tiltdeg); MT_Matrix3x3 tilt_mat = MT_Matrix3x3( - 1.0, 0.0, 0.0, - 0.0, c, -s, - 0.0, s, c + 1.0f, 0.0f, 0.0f, + 0.0f, c, -s, + 0.0f, s, c ); for (i =0;i<6;i++) @@ -1667,11 +1667,11 @@ void KX_Dome::DrawEnvMap(void) float ortho_width, ortho_height; if (warp.usemesh) - glOrtho((-1.0), 1.0, (-0.66), 0.66, -20.0, 10.0); //stretch the image to reduce resolution lost + glOrtho((-1.0), 1.0, (-0.66), 0.66, 0.0, 0.0); //stretch the image to reduce resolution lost else { if (can_width/3 <= can_height/2) { - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = (float)can_height/can_width; } else { @@ -1679,14 +1679,14 @@ void KX_Dome::DrawEnvMap(void) ortho_width = (float)can_width/can_height * ortho_height; } - glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt(0.0,0.0,1.0, 0.0,0.0,0.0, 0.0,1.0,0.0); + gluLookAt(0.0f,0.0f,1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f); glPolygonMode(GL_FRONT, GL_FILL); glShadeModel(GL_SMOOTH); @@ -1694,7 +1694,7 @@ void KX_Dome::DrawEnvMap(void) glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); - glColor3f(1.0,1.0,1.0); + glColor3f(1.0f,1.0f,1.0f); float uv_ratio = (float)(m_buffersize-1) / m_imagesize; double onebythree = 1.0f / 3; @@ -1704,11 +1704,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f( onebythree, 0.0f, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f(-onebythree, 0.0f, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f(-onebythree,-2 * onebythree, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(onebythree,-2 * onebythree, 3.0f); glEnd(); @@ -1717,11 +1717,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f(-onebythree, 0.0f, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f(-1.0f, 0.0f, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,-2 * onebythree, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(-onebythree,-2 * onebythree, 3.0f); glEnd(); @@ -1730,11 +1730,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f(-onebythree, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f(-1.0f, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f, 0.0f, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(-onebythree, 0.0f, 3.0f); glEnd(); @@ -1743,11 +1743,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f( 1.0f, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f( onebythree, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f( onebythree, 0.0f, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(1.0f, 0.0f, 3.0f); glEnd(); @@ -1756,11 +1756,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f( 1.0f, 0.0f, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f( onebythree, 0.0f, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f( onebythree,-2 * onebythree, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(1.0f, -2 * onebythree, 3.0f); glEnd(); @@ -1769,11 +1769,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f( onebythree, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f(-onebythree, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f(-onebythree, 0.0f, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(onebythree, 0.0f, 3.0f); glEnd(); @@ -1798,40 +1798,40 @@ void KX_Dome::DrawDomeFisheye(void) if (m_mode == DOME_FISHEYE) { if (warp.usemesh) - glOrtho((-1.0), 1.0, (-1.0), 1.0, -20.0, 10.0); //stretch the image to reduce resolution lost + glOrtho((-1.0f), 1.0f, (-1.0f), 1.0f, -20.0f, 10.0f); //stretch the image to reduce resolution lost else { if (can_width < can_height) { - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = (float)can_height/can_width; } else { ortho_width = (float)can_width/can_height; - ortho_height = 1.0; + ortho_height = 1.0f; } - glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } } else if (m_mode == DOME_TRUNCATED_FRONT) { - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = 2.0f * ((float)can_height / can_width) - 1.0f; - glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_width, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_width, -20.0f, 10.0f); } else { //m_mode == DOME_TRUNCATED_REAR - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = 2.0f * ((float)can_height / can_width) - 1.0f; - glOrtho((-ortho_width), ortho_width, (-ortho_width), ortho_height, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_width), ortho_height, -20.0f, 10.0f); } glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt(0.0,-1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0); + gluLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f); if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME) glPolygonMode(GL_FRONT, GL_LINE); @@ -1843,7 +1843,7 @@ void KX_Dome::DrawDomeFisheye(void) glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); - glColor3f(1.0,1.0,1.0); + glColor3f(1.0f,1.0f,1.0f); if (dlistSupported) { for (i=0;i<m_numfaces;i++) { @@ -1890,16 +1890,16 @@ void KX_Dome::DrawPanorama(void) int can_width = m_viewport.GetRight(); int can_height = m_viewport.GetTop(); - float ortho_height = 1.0; - float ortho_width = 1.0; + float ortho_height = 1.0f; + float ortho_width = 1.0f; if (warp.usemesh) - glOrtho((-1.0), 1.0, (-0.5), 0.5, -20.0, 10.0); //stretch the image to reduce resolution lost + glOrtho((-1.0f), 1.0f, (-0.5f), 0.5f, -20.0f, 10.0f); //stretch the image to reduce resolution lost else { //using all the screen if ((can_width / 2) <= (can_height)) { - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = (float)can_height/can_width; } else { @@ -1907,14 +1907,14 @@ void KX_Dome::DrawPanorama(void) ortho_height = 0.5f; } - glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt(0.0,-1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0); + gluLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f); if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME) glPolygonMode(GL_FRONT, GL_LINE); @@ -1926,7 +1926,7 @@ void KX_Dome::DrawPanorama(void) glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); - glColor3f(1.0,1.0,1.0); + glColor3f(1.0f,1.0f,1.0f); if (dlistSupported) { for (i=0;i<m_numfaces;i++) { @@ -1975,14 +1975,14 @@ void KX_Dome::DrawDomeWarped(void) double screen_ratio = can_width/ (double) can_height; - glOrtho(-screen_ratio,screen_ratio,-1.0,1.0,-20.0,10.0); + glOrtho(-screen_ratio,screen_ratio,-1.0f,1.0f,-20.0f,10.0f); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt(0.0, 0.0, 1.0, 0.0,0.0,0.0, 0.0,1.0,0.0); + gluLookAt(0.0f, 0.0f, 1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f); if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME) glPolygonMode(GL_FRONT, GL_LINE); @@ -1994,7 +1994,7 @@ void KX_Dome::DrawDomeWarped(void) glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); - glColor3f(1.0,1.0,1.0); + glColor3f(1.0f,1.0f,1.0f); if (dlistSupported) { glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]); @@ -2036,7 +2036,7 @@ void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i) MT_Transform camtrans(cam->GetWorldToCamera()); MT_Matrix4x4 viewmat(camtrans); - m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->NodeGetLocalScaling(), 1.0); + m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->NodeGetLocalScaling(), 1.0f); cam->SetModelviewMatrix(viewmat); // restore the original orientation diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index 420f1f7eb98..364f8d4bfc6 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -193,15 +193,14 @@ void KX_FontObject::DrawFontText() const float aspect = m_fsize / size; /* Get a working copy of the OpenGLMatrix to use */ - double mat[16]; - memcpy(mat, this->GetOpenGLMatrix(), sizeof(double)*16); + float *mat = GetOpenGLMatrix(); /* Account for offset */ MT_Vector3 offset = this->NodeGetWorldOrientation() * m_offset * this->NodeGetWorldScaling(); mat[12] += offset[0]; mat[13] += offset[1]; mat[14] += offset[2]; /* Orient the spacing vector */ - MT_Vector3 spacing = MT_Vector3(0, m_fsize*m_line_spacing, 0); + MT_Vector3 spacing = MT_Vector3(0.0f, m_fsize*m_line_spacing, 0.0f); spacing = this->NodeGetWorldOrientation() * spacing * this->NodeGetWorldScaling()[1]; /* Draw each line, taking spacing into consideration */ diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 5e66250bd80..ad6447778e5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -83,11 +83,11 @@ #include "BLI_math.h" -static MT_Point3 dummy_point= MT_Point3(0.0, 0.0, 0.0); -static MT_Vector3 dummy_scaling = MT_Vector3(1.0, 1.0, 1.0); -static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3(1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0); +static MT_Point3 dummy_point= MT_Point3(0.0f, 0.0f, 0.0f); +static MT_Vector3 dummy_scaling = MT_Vector3(1.0f, 1.0f, 1.0f); +static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3(1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f); KX_GameObject::KX_GameObject( void* sgReplicationInfo, @@ -101,7 +101,7 @@ KX_GameObject::KX_GameObject( m_pBlenderGroupObject(NULL), m_bUseObjectColor(false), m_bIsNegativeScaling(false), - m_objectColor(1.0, 1.0, 1.0, 1.0), + m_objectColor(1.0f, 1.0f, 1.0f, 1.0f), m_bVisible(true), m_bCulled(true), m_bOccluder(false), @@ -354,9 +354,9 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom m_pPhysicsController->SuspendDynamics(ghost); } // Set us to our new scale, position, and orientation - scale2[0] = 1.0/scale2[0]; - scale2[1] = 1.0/scale2[1]; - scale2[2] = 1.0/scale2[2]; + scale2[0] = 1.0f/scale2[0]; + scale2[1] = 1.0f/scale2[1]; + scale2[2] = 1.0f/scale2[2]; scale1 = scale1 * scale2; MT_Matrix3x3 invori = obj->NodeGetWorldOrientation().inverse(); MT_Vector3 newpos = invori*(NodeGetWorldPosition()-obj->NodeGetWorldPosition())*scale2; @@ -700,10 +700,10 @@ void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local) /** * GetOpenGL Matrix, returns an OpenGL 'compatible' matrix */ -double* KX_GameObject::GetOpenGLMatrix() +float *KX_GameObject::GetOpenGLMatrix() { // todo: optimize and only update if necessary - double* fl = m_OpenGL_4x4Matrix.getPointer(); + float *fl = m_OpenGL_4x4Matrix.getPointer(); if (GetSGNode()) { MT_Transform trans; @@ -711,7 +711,7 @@ double* KX_GameObject::GetOpenGLMatrix() trans.setBasis(GetSGNode()->GetWorldOrientation()); MT_Vector3 scaling = GetSGNode()->GetWorldScaling(); - m_bIsNegativeScaling = ((scaling[0] < 0.0) ^ (scaling[1] < 0.0) ^ (scaling[2] < 0.0)) ? true : false; + m_bIsNegativeScaling = ((scaling[0] < 0.0f) ^ (scaling[1] < 0.0f) ^ (scaling[2] < 0.0f)) ? true : false; trans.scale(scaling[0], scaling[1], scaling[2]); trans.getValue(fl); GetSGNode()->ClearDirty(); @@ -742,7 +742,7 @@ void KX_GameObject::AddMeshUser() m_meshes[i]->AddMeshUser(this, &m_meshSlots, GetDeformer()); } // set the part of the mesh slot that never change - double* fl = GetOpenGLMatrixPtr()->getPointer(); + float *fl = GetOpenGLMatrixPtr()->getPointer(); SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots); // RAS_MeshSlot* ms; @@ -1214,12 +1214,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) { case 0: //x axis ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis - if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector parallel to the pivot? + if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) //is the vector parallel to the pivot? ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot! if (fac == 1.0f) { x = vect; } else { - x = (vect * fac) + ((orimat * MT_Vector3(1.0, 0.0, 0.0)) * (1.0f - fac)); + x = (vect * fac) + ((orimat * MT_Vector3(1.0f, 0.0f, 0.0f)) * (1.0f - fac)); len = x.length(); if (MT_fuzzyZero(len)) x = vect; else x /= len; @@ -1229,12 +1229,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) break; case 1: //y axis ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]); - if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) + if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); if (fac == 1.0f) { y = vect; } else { - y = (vect * fac) + ((orimat * MT_Vector3(0.0, 1.0, 0.0)) * (1.0f - fac)); + y = (vect * fac) + ((orimat * MT_Vector3(0.0f, 1.0f, 0.0f)) * (1.0f - fac)); len = y.length(); if (MT_fuzzyZero(len)) y = vect; else y /= len; @@ -1244,12 +1244,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) break; case 2: //z axis ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); - if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) + if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]); if (fac == 1.0f) { z = vect; } else { - z = (vect * fac) + ((orimat * MT_Vector3(0.0, 0.0, 1.0)) * (1.0f - fac)); + z = (vect * fac) + ((orimat * MT_Vector3(0.0f, 0.0f, 1.0f)) * (1.0f - fac)); len = z.length(); if (MT_fuzzyZero(len)) z = vect; else z /= len; @@ -1284,12 +1284,12 @@ MT_Scalar KX_GameObject::GetMass() { return m_pPhysicsController->GetMass(); } - return 0.0; + return 0.0f; } MT_Vector3 KX_GameObject::GetLocalInertia() { - MT_Vector3 local_inertia(0.0,0.0,0.0); + MT_Vector3 local_inertia(0.0f,0.0f,0.0f); if (m_pPhysicsController) { local_inertia = m_pPhysicsController->GetLocalInertia(); @@ -1299,7 +1299,7 @@ MT_Vector3 KX_GameObject::GetLocalInertia() MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { - MT_Vector3 velocity(0.0,0.0,0.0), locvel; + MT_Vector3 velocity(0.0f,0.0f,0.0f), locvel; MT_Matrix3x3 ori; if (m_pPhysicsController) { @@ -1318,7 +1318,7 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) { - MT_Vector3 velocity(0.0,0.0,0.0), locvel; + MT_Vector3 velocity(0.0f,0.0f,0.0f), locvel; MT_Matrix3x3 ori; if (m_pPhysicsController) { @@ -1341,7 +1341,7 @@ MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point) { return m_pPhysicsController->GetVelocity(point); } - return MT_Vector3(0.0,0.0,0.0); + return MT_Vector3(0.0f,0.0f,0.0f); } // scenegraph node stuff @@ -1468,9 +1468,9 @@ void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans) { return; } - scale[0] = 1.0/scale[0]; - scale[1] = 1.0/scale[1]; - scale[2] = 1.0/scale[2]; + scale[0] = 1.0f/scale[0]; + scale[1] = 1.0f/scale[1]; + scale[2] = 1.0f/scale[2]; MT_Matrix3x3 invori = parent->GetWorldOrientation().inverse(); MT_Vector3 newpos = invori*(trans-parent->GetWorldPosition())*scale; NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2])); @@ -2421,7 +2421,7 @@ PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF CValue *life = self->GetProperty("::timebomb"); if (life) - // this convert the timebomb seconds to frames, hard coded 50.0 (assuming 50fps) + // this convert the timebomb seconds to frames, hard coded 50.0f (assuming 50fps) // value hardcoded in KX_Scene::AddReplicaObject() return PyFloat_FromDouble(life->GetNumber() * 50.0); else @@ -2432,7 +2432,7 @@ PyObject *KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF { KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PHY_IPhysicsController *spc = self->GetPhysicsController(); - return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0); + return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0f); } int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -2440,7 +2440,7 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); - if (val < 0.0) { /* also accounts for non float */ + if (val < 0.0f) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above"); return PY_SET_ATTR_FAIL; } @@ -2476,7 +2476,7 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); - if (val < 0.0) { /* also accounts for non float */ + if (val < 0.0f) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above"); return PY_SET_ATTR_FAIL; } @@ -2499,7 +2499,7 @@ int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); - if (val < 0.0) { /* also accounts for non float */ + if (val < 0.0f) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above"); return PY_SET_ATTR_FAIL; } @@ -2768,7 +2768,7 @@ PyObject *KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTR { KX_GameObject* self = static_cast<KX_GameObject*>(self_v); - double mat[16]; + float mat[16]; MT_Transform trans; @@ -2976,7 +2976,7 @@ PyObject *KX_GameObject::pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUT if (self->GetSGNode() && (sg_parent = self->GetSGNode()->GetSGParent()) != NULL && sg_parent->IsSlowParent()) { return PyFloat_FromDouble(static_cast<KX_SlowParentRelation *>(sg_parent->GetParentRelation())->GetTimeOffset()); } else { - return PyFloat_FromDouble(0.0); + return PyFloat_FromDouble(0.0f); } } @@ -2986,7 +2986,7 @@ int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF if (self->GetSGNode()) { MT_Scalar val = PyFloat_AsDouble(value); SG_Node *sg_parent= self->GetSGNode()->GetSGParent(); - if (val < 0.0) { /* also accounts for non float */ + if (val < 0.0f) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.timeOffset = float: KX_GameObject, expected a float zero or above"); return PY_SET_ATTR_FAIL; } @@ -3366,7 +3366,7 @@ PyObject *KX_GameObject::PySetOcclusion(PyObject *args) PyObject *KX_GameObject::PyGetVelocity(PyObject *args) { // only can get the velocity if we have a physics object connected to us... - MT_Point3 point(0.0,0.0,0.0); + MT_Point3 point(0.0f,0.0f,0.0f); PyObject *pypos = NULL; if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point))) @@ -3386,7 +3386,7 @@ PyObject *KX_GameObject::PyGetReactionForce() return PyObjectFrom(dummy_point); #endif - return Py_BuildValue("fff", 0.0, 0.0, 0.0); + return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f); } @@ -3619,8 +3619,8 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo, if (MT_fuzzyZero(distance)) { //cout << "getVectTo() Error: Null vector!\n"; - locToDir = toDir = MT_Vector3(0.0,0.0,0.0); - distance = 0.0; + locToDir = toDir = MT_Vector3(0.0f,0.0f,0.0f); + distance = 0.0f; } else { toDir.normalize(); locToDir = toDir * NodeGetWorldOrientation(); @@ -3736,8 +3736,9 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, RayCastData rayData(propName, false, (1 << OB_MAX_COL_MASKS) - 1); KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData); - if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback)) + if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) { return rayData.m_hitObject->GetProxy(); + } Py_RETURN_NONE; } @@ -3883,8 +3884,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, RayCastData rayData(propName, xray, mask); KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData, face, (poly == 2)); - if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback)) - { + if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) { PyObject *returnValue = (poly == 2) ? PyTuple_New(5) : (poly) ? PyTuple_New(4) : PyTuple_New(3); if (returnValue) { // unlikely this would ever fail, if it does python sets an error PyTuple_SET_ITEM(returnValue, 0, rayData.m_hitObject->GetProxy()); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index c2c455dab6a..a25f999026c 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -175,7 +175,7 @@ public: * side effect of storing the result internally. The * memory for the matrix remains the property of this class. */ - double * + float * GetOpenGLMatrix( ); diff --git a/source/gameengine/Ketsji/KX_IPOTransform.h b/source/gameengine/Ketsji/KX_IPOTransform.h index a68292bf9df..a81c432b01e 100644 --- a/source/gameengine/Ketsji/KX_IPOTransform.h +++ b/source/gameengine/Ketsji/KX_IPOTransform.h @@ -38,12 +38,12 @@ class KX_IPOTransform { public: KX_IPOTransform() : - m_position(0.0, 0.0, 0.0), - m_eulerAngles(0.0, 0.0, 0.0), - m_scaling(1.0, 1.0, 1.0), - m_deltaPosition(0.0, 0.0, 0.0), - m_deltaEulerAngles(0.0, 0.0, 0.0), - m_deltaScaling(0.0, 0.0, 0.0) + m_position(0.0f, 0.0f, 0.0f), + m_eulerAngles(0.0f, 0.0f, 0.0f), + m_scaling(1.0f, 1.0f, 1.0f), + m_deltaPosition(0.0f, 0.0f, 0.0f), + m_deltaEulerAngles(0.0f, 0.0f, 0.0f), + m_deltaScaling(0.0f, 0.0f, 0.0f) {} MT_Transform GetTransform() const { @@ -69,9 +69,9 @@ public: void SetScaling(const MT_Vector3& scaling) { m_scaling = scaling; } void ClearDeltaStuff() { - m_deltaPosition.setValue(0.0, 0.0, 0.0); - m_deltaEulerAngles.setValue(0.0, 0.0, 0.0); - m_deltaScaling.setValue(0.0, 0.0, 0.0); + m_deltaPosition.setValue(0.0f, 0.0f, 0.0f); + m_deltaEulerAngles.setValue(0.0f, 0.0f, 0.0f); + m_deltaScaling.setValue(0.0f, 0.0f, 0.0f); } protected: diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 2683c21f8eb..43cb62bc731 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -128,6 +128,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_bInitialized(false), m_activecam(0), m_bFixedTime(false), + m_useExternalClock(false), m_firstframe(true), @@ -135,17 +136,19 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_clockTime(0.f), m_previousClockTime(0.f), m_previousAnimTime(0.f), + m_timescale(1.0f), + m_previousRealTime(0.0f), m_exitcode(KX_EXIT_REQUEST_NO_REQUEST), m_exitstring(""), - m_cameraZoom(1.0), + m_cameraZoom(1.0f), m_overrideCam(false), m_overrideCamUseOrtho(false), - m_overrideCamNear(0.0), - m_overrideCamFar(0.0), + m_overrideCamNear(0.0f), + m_overrideCamFar(0.0f), m_overrideCamZoom(1.0f), m_stereo(false), @@ -167,10 +170,10 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_hideCursor(false), m_overrideFrameColor(false), - m_overrideFrameColorR(0.0), - m_overrideFrameColorG(0.0), - m_overrideFrameColorB(0.0), - m_overrideFrameColorA(0.0), + m_overrideFrameColorR(0.0f), + m_overrideFrameColorG(0.0f), + m_overrideFrameColorB(0.0f), + m_overrideFrameColorA(0.0f), m_usedome(false) { @@ -412,6 +415,7 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo) m_clockTime = m_kxsystem->GetTimeInSeconds(); m_frameTime = m_kxsystem->GetTimeInSeconds(); m_previousClockTime = m_kxsystem->GetTimeInSeconds(); + m_previousRealTime = m_kxsystem->GetTimeInSeconds(); m_firstframe = true; m_bInitialized = true; @@ -526,8 +530,8 @@ void KX_KetsjiEngine::EndFrame() for (int i = tc_first; i < tc_numCategories; ++i) { double 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)); + PyTuple_SetItem(val, 0, PyFloat_FromDouble(time*1000.0)); + PyTuple_SetItem(val, 1, PyFloat_FromDouble(time/tottime * 100.0)); PyDict_SetItemString(m_pyprofiledict, m_profileLabels[i], val); Py_DECREF(val); @@ -555,7 +559,7 @@ void KX_KetsjiEngine::EndFrame() bool KX_KetsjiEngine::NextFrame() { - double timestep = 1.0/m_ticrate; + double timestep = m_timescale / m_ticrate; double framestep = timestep; // static hidden::Clock sClock; @@ -564,32 +568,61 @@ bool KX_KetsjiEngine::NextFrame() //float dt = sClock.getTimeMicroseconds() * 0.000001f; //sClock.reset(); - if (m_bFixedTime) { - m_clockTime += timestep; - } - else { - // m_clockTime += dt; - m_clockTime = m_kxsystem->GetTimeInSeconds(); + /* + * Clock advancement. There is basically three case: + * - m_useExternalClock is true, the user is responsible to advance the time + * manually using setClockTime, so here, we do not do anything. + * - m_useExternalClock is false, m_bFixedTime is true, we advance for one + * timestep, which already handle the time scaling parameter + * - m_useExternalClock is false, m_bFixedTime is false, we consider how much + * time has elapsed since last call and we scale this time by the time + * scaling parameter. If m_timescale is 1.0 (default value), the clock + * corresponds to the computer clock. + * + * Once clockTime has been computed, we will compute how many logic frames + * will be executed before the next rendering phase (which will occur at "clockTime"). + * The game time elapsing between two logic frames (called framestep) + * depends on several variables: + * - ticrate + * - max_physic_frame + * - max_logic_frame + * XXX The logic over computation framestep is definitively not clear (and + * I'm not even sure it is correct). If needed frame is strictly greater + * than max_physics_frame, we are doing a jump in game time, but keeping + * framestep = 1 / ticrate, while if frames is greater than + * max_logic_frame, we increase framestep. + * + * XXX render.fps is not considred anywhere. + */ + if (!m_useExternalClock) { + if (m_bFixedTime) { + m_clockTime += timestep; + } + else { + double current_time = m_kxsystem->GetTimeInSeconds(); + double dt = current_time - m_previousRealTime; + m_previousRealTime = current_time; + // m_clockTime += dt; + m_clockTime += dt * m_timescale; + } } double deltatime = m_clockTime - m_frameTime; - if (deltatime<0.f) + if (deltatime<0.0) { // 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; } - // Compute the number of logic frames to do each update (fixed tic bricks) - int frames =int(deltatime*m_ticrate+1e-6); + int frames = int(deltatime * m_ticrate / m_timescale + 1e-6); // if (frames>1) // printf("****************************************"); // printf("dt = %f, deltatime = %f, frames = %d\n",dt, deltatime,frames); // if (!frames) // PIL_sleep_ms(1); - KX_SceneList::iterator sceneit; if (frames>m_maxPhysicsFrame) @@ -1352,8 +1385,8 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene) activecam->NodeSetLocalOrientation(camtrans.getBasis()); activecam->NodeUpdateGS(0); } else { - activecam->NodeSetLocalPosition(MT_Point3(0.0, 0.0, 0.0)); - activecam->NodeSetLocalOrientation(MT_Vector3(0.0, 0.0, 0.0)); + activecam->NodeSetLocalPosition(MT_Point3(0.0f, 0.0f, 0.0f)); + activecam->NodeSetLocalOrientation(MT_Vector3(0.0f, 0.0f, 0.0f)); activecam->NodeUpdateGS(0); } @@ -1418,7 +1451,7 @@ void KX_KetsjiEngine::RenderDebugProperties() m_canvas->GetWidth() /* RdV, TODO ?? */, m_canvas->GetHeight() /* RdV, TODO ?? */); - debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.f, 1.0/tottime); + debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.0f, 1.0f/tottime); m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), xcoord + const_xindent + profile_indent, @@ -1441,14 +1474,14 @@ void KX_KetsjiEngine::RenderDebugProperties() double time = m_logger->GetAverage((KX_TimeCategory)j); - debugtxt.Format("%5.2fms | %d%%", time*1000.f, (int)(time/tottime * 100.f)); + debugtxt.Format("%5.2fms | %d%%", (float)time*1000.f, (int)((float)time/tottime * 100.f)); m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), xcoord + const_xindent + profile_indent, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); - m_rasterizer->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime); + m_rasterizer->RenderBox2D(xcoord + (int)(2.2f * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), (float)time/tottime); ycoord += const_ysize; } } @@ -1762,6 +1795,10 @@ void KX_KetsjiEngine::SetUseFixedTime(bool bUseFixedTime) m_bFixedTime = bUseFixedTime; } +void KX_KetsjiEngine::SetUseExternalClock(bool useExternalClock) +{ + m_useExternalClock = useExternalClock; +} void KX_KetsjiEngine::SetAnimRecordMode(bool animation_record, int startFrame) { @@ -1789,6 +1826,11 @@ bool KX_KetsjiEngine::GetUseFixedTime(void) const return m_bFixedTime; } +bool KX_KetsjiEngine::GetUseExternalClock(void) const +{ + return m_useExternalClock; +} + double KX_KetsjiEngine::GetSuspendedDelta() { return m_suspendeddelta; @@ -1804,6 +1846,16 @@ void KX_KetsjiEngine::SetTicRate(double ticrate) m_ticrate = ticrate; } +double KX_KetsjiEngine::GetTimeScale() const +{ + return m_timescale; +} + +void KX_KetsjiEngine::SetTimeScale(double timescale) +{ + m_timescale = timescale; +} + int KX_KetsjiEngine::GetMaxLogicFrame() { return m_maxLogicFrame; @@ -1844,6 +1896,11 @@ double KX_KetsjiEngine::GetClockTime(void) const return m_clockTime; } +void KX_KetsjiEngine::SetClockTime(double externalClockTime) +{ + m_clockTime = externalClockTime; +} + double KX_KetsjiEngine::GetFrameTime(void) const { return m_frameTime; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 660a6adb86f..4be5f0074f5 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -103,15 +103,18 @@ private: bool m_bInitialized; int m_activecam; bool m_bFixedTime; + bool m_useExternalClock; bool m_firstframe; int m_currentFrame; - double m_frameTime;//discrete timestamp of the 'game logic frame' - double m_clockTime;//current time - double m_previousClockTime;//previous clock time - double m_previousAnimTime; //the last time animations were updated + double m_frameTime; // current logic game time + double m_clockTime; // game time for the next rendering step + double m_previousClockTime; // game time of the previous rendering step + double m_previousAnimTime; //game time when the animations were last updated double m_remainingTime; + double m_timescale; // time scaling parameter. if > 1.0, time goes faster than real-time. If < 1.0, times goes slower than real-time. + double m_previousRealTime; static int m_maxLogicFrame; /* maximum number of consecutive logic frame */ static int m_maxPhysicsFrame; /* maximum number of consecutive physics frame */ @@ -300,15 +303,37 @@ public: bool GetUseFixedTime(void) const; /** - * Returns current render frame clock time + * Sets if the BGE relies on a external clock or its own internal clock + */ + void SetUseExternalClock(bool bUseExternalClock); + + /** + * Returns if we rely on an external clock + * \return Current setting + */ + bool GetUseExternalClock(void) const; + + /** + * Returns next render frame game time */ double GetClockTime(void) const; + + /** + * Set the next render frame game time. It will impact also frame time, as + * this one is derived from clocktime + */ + void SetClockTime(double externalClockTime); + /** - * Returns current logic frame clock time + * Returns current logic frame game time */ double GetFrameTime(void) const; + /** + * Returns the real (system) time + */ double GetRealTime(void) const; + /** * Returns the difference between the local time of the scene (when it * was running and not suspended) and the "curtime" @@ -364,6 +389,16 @@ public: */ static double GetAverageFrameRate(); + /** + * Gets the time scale multiplier + */ + double GetTimeScale() const; + + /** + * Sets the time scale multiplier + */ + void SetTimeScale(double scale); + static void SetExitKey(short key); static short GetExitKey(); diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 0dec5715588..b681f10804a 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -231,8 +231,8 @@ int KX_LightObject::pyattr_set_distance(void *self_v, const KX_PYATTRIBUTE_DEF * if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); - if (val < 0.01) - val = 0.01; + if (val < 0.01f) + val = 0.01f; else if (val > 5000.f) val = 5000.f; @@ -326,13 +326,13 @@ int KX_LightObject::pyattr_set_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF * KX_LightObject* self = static_cast<KX_LightObject*>(self_v); if (PyFloat_Check(value)) { - float val = PyFloat_AsDouble(value); - if (val < 0.f) - val = 0.f; - else if (val > 180.f) - val = 180.f; + double val = PyFloat_AsDouble(value); + if (val < 0.0) + val = 0.0; + else if (val > 180.0) + val = 180.0; - self->m_lightobj->m_spotsize = DEG2RAD(val); + self->m_lightobj->m_spotsize = (float)DEG2RAD(val); return PY_SET_ATTR_SUCCESS; } @@ -350,7 +350,7 @@ int KX_LightObject::pyattr_set_spotblend(void *self_v, const KX_PYATTRIBUTE_DEF KX_LightObject* self = static_cast<KX_LightObject*>(self_v); if (PyFloat_Check(value)) { - float val = PyFloat_AsDouble(value); + float val = (float)PyFloat_AsDouble(value); if (val < 0.f) val = 0.f; else if (val > 1.f) diff --git a/source/gameengine/Ketsji/KX_MouseActuator.cpp b/source/gameengine/Ketsji/KX_MouseActuator.cpp index 154ad1da3a1..6aa0d588b50 100644 --- a/source/gameengine/Ketsji/KX_MouseActuator.cpp +++ b/source/gameengine/Ketsji/KX_MouseActuator.cpp @@ -125,8 +125,8 @@ bool KX_MouseActuator::Update() float position[2]; float movement[2]; MT_Vector3 rotation; - float setposition[2] = {0.0}; - float center_x = 0.5, center_y = 0.5; + float setposition[2] = {0.0f}; + float center_x = 0.5f, center_y = 0.5f; getMousePosition(position); @@ -135,14 +135,14 @@ bool KX_MouseActuator::Update() //preventing undesired drifting when resolution is odd if ((m_canvas->GetWidth() % 2) != 0) { - center_x = ((m_canvas->GetWidth() - 1.0) / 2.0) / (m_canvas->GetWidth()); + center_x = ((m_canvas->GetWidth() - 1.0f) / 2.0f) / (m_canvas->GetWidth()); } if ((m_canvas->GetHeight() % 2) != 0) { - center_y = ((m_canvas->GetHeight() - 1.0) / 2.0) / (m_canvas->GetHeight()); + center_y = ((m_canvas->GetHeight() - 1.0f) / 2.0f) / (m_canvas->GetHeight()); } //preventing initial skipping. - if ((m_oldposition[0] <= -0.9) && (m_oldposition[1] <= -0.9)) { + if ((m_oldposition[0] <= -0.9f) && (m_oldposition[1] <= -0.9f)) { if (m_reset_x) { m_oldposition[0] = center_x; @@ -173,21 +173,21 @@ bool KX_MouseActuator::Update() movement[0] -= m_oldposition[0]; } - movement[0] *= -1.0; + movement[0] *= -1.0f; /* Don't apply the rotation when we are under a certain threshold for mouse movement */ - if (((movement[0] > (m_threshold[0] / 10.0)) || - ((movement[0] * (-1.0)) > (m_threshold[0] / 10.0)))) { + if (((movement[0] > (m_threshold[0] / 10.0f)) || + ((movement[0] * (-1.0f)) > (m_threshold[0] / 10.0f)))) { movement[0] *= m_sensitivity[0]; - if ((m_limit_x[0] != 0.0) && ((m_angle[0] + movement[0]) <= m_limit_x[0])) { + if ((m_limit_x[0] != 0.0f) && ((m_angle[0] + movement[0]) <= m_limit_x[0])) { movement[0] = m_limit_x[0] - m_angle[0]; } - if ((m_limit_x[1] != 0.0) && ((m_angle[0] + movement[0]) >= m_limit_x[1])) { + if ((m_limit_x[1] != 0.0f) && ((m_angle[0] + movement[0]) >= m_limit_x[1])) { movement[0] = m_limit_x[1] - m_angle[0]; } @@ -196,17 +196,17 @@ bool KX_MouseActuator::Update() switch (m_object_axis[0]) { case KX_ACT_MOUSE_OBJECT_AXIS_X: { - rotation = MT_Vector3(movement[0], 0.0, 0.0); + rotation = MT_Vector3(movement[0], 0.0f, 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Y: { - rotation = MT_Vector3(0.0, movement[0], 0.0); + rotation = MT_Vector3(0.0f, movement[0], 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Z: { - rotation = MT_Vector3(0.0, 0.0, movement[0]); + rotation = MT_Vector3(0.0f, 0.0f, movement[0]); break; } default: @@ -231,21 +231,21 @@ bool KX_MouseActuator::Update() movement[1] -= m_oldposition[1]; } - movement[1] *= -1.0; + movement[1] *= -1.0f; /* Don't apply the rotation when we are under a certain threshold for mouse movement */ - if (((movement[1] > (m_threshold[1] / 10.0)) || - ((movement[1] * (-1.0)) > (m_threshold[1] / 10.0)))) { + if (((movement[1] > (m_threshold[1] / 10.0f)) || + ((movement[1] * (-1.0f)) > (m_threshold[1] / 10.0f)))) { movement[1] *= m_sensitivity[1]; - if ((m_limit_y[0] != 0.0) && ((m_angle[1] + movement[1]) <= m_limit_y[0])) { + if ((m_limit_y[0] != 0.0f) && ((m_angle[1] + movement[1]) <= m_limit_y[0])) { movement[1] = m_limit_y[0] - m_angle[1]; } - if ((m_limit_y[1] != 0.0) && ((m_angle[1] + movement[1]) >= m_limit_y[1])) { + if ((m_limit_y[1] != 0.0f) && ((m_angle[1] + movement[1]) >= m_limit_y[1])) { movement[1] = m_limit_y[1] - m_angle[1]; } @@ -255,17 +255,17 @@ bool KX_MouseActuator::Update() { case KX_ACT_MOUSE_OBJECT_AXIS_X: { - rotation = MT_Vector3(movement[1], 0.0, 0.0); + rotation = MT_Vector3(movement[1], 0.0f, 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Y: { - rotation = MT_Vector3(0.0, movement[1], 0.0); + rotation = MT_Vector3(0.0f, movement[1], 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Z: { - rotation = MT_Vector3(0.0, 0.0, movement[1]); + rotation = MT_Vector3(0.0f, 0.0f, movement[1]); break; } default: @@ -377,7 +377,7 @@ PyAttributeDef KX_MouseActuator::Attributes[] = { KX_PYATTRIBUTE_BOOL_RW("visible", KX_MouseActuator, m_visible), KX_PYATTRIBUTE_BOOL_RW("use_axis_x", KX_MouseActuator, m_use_axis_x), KX_PYATTRIBUTE_BOOL_RW("use_axis_y", KX_MouseActuator, m_use_axis_y), - KX_PYATTRIBUTE_FLOAT_ARRAY_RW("threshold", 0.0, 0.5, KX_MouseActuator, m_threshold, 2), + KX_PYATTRIBUTE_FLOAT_ARRAY_RW("threshold", 0.0f, 0.5f, KX_MouseActuator, m_threshold, 2), KX_PYATTRIBUTE_BOOL_RW("reset_x", KX_MouseActuator, m_reset_x), KX_PYATTRIBUTE_BOOL_RW("reset_y", KX_MouseActuator, m_reset_y), KX_PYATTRIBUTE_INT_ARRAY_RW("object_axis", 0, 2, 1, KX_MouseActuator, m_object_axis, 2), @@ -393,7 +393,7 @@ PyAttributeDef KX_MouseActuator::Attributes[] = { PyObject* KX_MouseActuator::pyattr_get_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v); - return Py_BuildValue("[f,f]", (self->m_limit_x[0] / M_PI * 180.0), (self->m_limit_x[1] / M_PI * 180.0)); + return Py_BuildValue("[f,f]", (self->m_limit_x[0] / (float)M_PI * 180.0f), (self->m_limit_x[1] / (float)M_PI * 180.0f)); } int KX_MouseActuator::pyattr_set_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -414,8 +414,8 @@ int KX_MouseActuator::pyattr_set_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_FAIL; } else { - self->m_limit_x[0] = (PyFloat_AsDouble(item1) * M_PI / 180.0); - self->m_limit_x[1] = (PyFloat_AsDouble(item2) * M_PI / 180.0); + self->m_limit_x[0] = (float)((PyFloat_AsDouble(item1) * M_PI) / 180.0f); + self->m_limit_x[1] = (float)((PyFloat_AsDouble(item2) * M_PI) / 180.0f); } return PY_SET_ATTR_SUCCESS; @@ -424,7 +424,7 @@ int KX_MouseActuator::pyattr_set_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF PyObject* KX_MouseActuator::pyattr_get_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v); - return Py_BuildValue("[f,f]", (self->m_limit_y[0] / M_PI * 180.0), (self->m_limit_y[1] / M_PI * 180.0)); + return Py_BuildValue("[f,f]", (self->m_limit_y[0] / (float)M_PI * 180.0f), (self->m_limit_y[1] / (float)M_PI * 180.0f)); } int KX_MouseActuator::pyattr_set_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -445,8 +445,8 @@ int KX_MouseActuator::pyattr_set_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_FAIL; } else { - self->m_limit_y[0] = (PyFloat_AsDouble(item1) * M_PI / 180.0); - self->m_limit_y[1] = (PyFloat_AsDouble(item2) * M_PI / 180.0); + self->m_limit_y[0] = (float)((PyFloat_AsDouble(item1) * M_PI) / 180.0f); + self->m_limit_y[1] = (float)((PyFloat_AsDouble(item2) * M_PI) / 180.0f); } return PY_SET_ATTR_SUCCESS; @@ -455,7 +455,7 @@ int KX_MouseActuator::pyattr_set_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF PyObject* KX_MouseActuator::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v); - return Py_BuildValue("[f,f]", (self->m_angle[0] / M_PI * 180.0), (self->m_angle[1] / M_PI * 180.0)); + return Py_BuildValue("[f,f]", (self->m_angle[0] / (float)M_PI * 180.0f), (self->m_angle[1] / (float)M_PI * 180.0f)); } int KX_MouseActuator::pyattr_set_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -476,8 +476,8 @@ int KX_MouseActuator::pyattr_set_angle(void *self_v, const KX_PYATTRIBUTE_DEF *a return PY_SET_ATTR_FAIL; } else { - self->m_angle[0] = (PyFloat_AsDouble(item1) * M_PI / 180.0); - self->m_angle[1] = (PyFloat_AsDouble(item2) * M_PI / 180.0); + self->m_angle[0] = ((float)(PyFloat_AsDouble(item1) * M_PI) / 180.0f); + self->m_angle[1] = ((float)(PyFloat_AsDouble(item2) * M_PI) / 180.0f); } return PY_SET_ATTR_SUCCESS; @@ -491,17 +491,17 @@ PyObject* KX_MouseActuator::PyReset() switch (m_object_axis[0]) { case KX_ACT_MOUSE_OBJECT_AXIS_X: { - rotation = MT_Vector3(-1.0 * m_angle[0], 0.0, 0.0); + rotation = MT_Vector3(-1.0f * m_angle[0], 0.0f, 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Y: { - rotation = MT_Vector3(0.0, -1.0 * m_angle[0], 0.0); + rotation = MT_Vector3(0.0f, -1.0f * m_angle[0], 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Z: { - rotation = MT_Vector3(0.0, 0.0, -1.0 * m_angle[0]); + rotation = MT_Vector3(0.0f, 0.0f, -1.0f * m_angle[0]); break; } default: @@ -512,17 +512,17 @@ PyObject* KX_MouseActuator::PyReset() switch (m_object_axis[1]) { case KX_ACT_MOUSE_OBJECT_AXIS_X: { - rotation = MT_Vector3(-1.0 * m_angle[1], 0.0, 0.0); + rotation = MT_Vector3(-1.0f * m_angle[1], 0.0f, 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Y: { - rotation = MT_Vector3(0.0, -1.0 * m_angle[1], 0.0); + rotation = MT_Vector3(0.0f, -1.0f * m_angle[1], 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Z: { - rotation = MT_Vector3(0.0, 0.0, -1.0 * m_angle[1]); + rotation = MT_Vector3(0.0f, 0.0f, -1.0f * m_angle[1]); break; } default: @@ -530,8 +530,8 @@ PyObject* KX_MouseActuator::PyReset() } parent->ApplyRotation(rotation, m_local_y); - m_angle[0] = 0.0; - m_angle[1] = 0.0; + m_angle[0] = 0.0f; + m_angle[1] = 0.0f; Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index db2cb1fdcfd..451078d4a36 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -314,15 +314,15 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) * The actual z coordinates used don't have to be exact just infront and * behind of the near and far clip planes. */ - frompoint.setValue( (2 * (m_x-x_lb) / width) - 1.0, - 1.0 - (2 * (m_y_inv - y_lb) / height), - -1.0, - 1.0 ); + frompoint.setValue( (2 * (m_x-x_lb) / width) - 1.0f, + 1.0f - (2 * (m_y_inv - y_lb) / height), + -1.0f, + 1.0f ); - topoint.setValue( (2 * (m_x-x_lb) / width) - 1.0, - 1.0 - (2 * (m_y_inv-y_lb) / height), - 1.0, - 1.0 ); + topoint.setValue( (2 * (m_x-x_lb) / width) - 1.0f, + 1.0f - (2 * (m_y_inv-y_lb) / height), + 1.0f, + 1.0f ); /* camera to world */ MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cam->GetCameraToWorld()); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 762148d8f76..87c2592ecfd 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -65,12 +65,12 @@ KX_ObjectActuator( m_drot(drot), m_linear_velocity(linV), m_angular_velocity(angV), - m_linear_length2(0.0), - m_current_linear_factor(0.0), - m_current_angular_factor(0.0), + m_linear_length2(0.0f), + m_current_linear_factor(0.0f), + m_current_angular_factor(0.0f), m_damping(damping), - m_previous_error(0.0,0.0,0.0), - m_error_accumulator(0.0,0.0,0.0), + m_previous_error(0.0f,0.0f,0.0f), + m_error_accumulator(0.0f,0.0f,0.0f), m_bitLocalFlag (flag), m_reference(refobj), m_active_combined_velocity (false), @@ -134,13 +134,13 @@ bool KX_ObjectActuator::Update() // Explicitly stop the movement if we're using character motion if (m_bitLocalFlag.CharacterMotion) { - character->SetWalkDirection(MT_Vector3 (0.0, 0.0, 0.0)); + character->SetWalkDirection(MT_Vector3 (0.0f, 0.0f, 0.0f)); } m_linear_damping_active = false; m_angular_damping_active = false; - m_error_accumulator.setValue(0.0,0.0,0.0); - m_previous_error.setValue(0.0,0.0,0.0); + m_error_accumulator.setValue(0.0f,0.0f,0.0f); + m_previous_error.setValue(0.0f,0.0f,0.0f); m_jumping = false; return false; @@ -299,10 +299,10 @@ bool KX_ObjectActuator::Update() m_current_linear_factor = linV.dot(m_linear_velocity)/m_linear_length2; m_linear_damping_active = true; } - if (m_current_linear_factor < 1.0) - m_current_linear_factor += 1.0/m_damping; - if (m_current_linear_factor > 1.0) - m_current_linear_factor = 1.0; + if (m_current_linear_factor < 1.0f) + m_current_linear_factor += 1.0f/m_damping; + if (m_current_linear_factor > 1.0f) + m_current_linear_factor = 1.0f; linV = m_current_linear_factor * m_linear_velocity; parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); } else { @@ -327,10 +327,10 @@ bool KX_ObjectActuator::Update() m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2; m_angular_damping_active = true; } - if (m_current_angular_factor < 1.0) - m_current_angular_factor += 1.0/m_damping; - if (m_current_angular_factor > 1.0) - m_current_angular_factor = 1.0; + if (m_current_angular_factor < 1.0f) + m_current_angular_factor += 1.0f/m_damping; + if (m_current_angular_factor > 1.0f) + m_current_angular_factor = 1.0f; angV = m_current_angular_factor * m_angular_velocity; parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); } else { diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index b5622d97611..919c6acf03b 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -161,9 +161,9 @@ public: m_bitLocalFlag.ZeroDLoc = MT_fuzzyZero(m_dloc); m_bitLocalFlag.ZeroDRot = MT_fuzzyZero(m_drot); m_bitLocalFlag.ZeroLinearVelocity = MT_fuzzyZero(m_linear_velocity); - m_linear_length2 = (m_bitLocalFlag.ZeroLinearVelocity) ? 0.0 : m_linear_velocity.length2(); + m_linear_length2 = (m_bitLocalFlag.ZeroLinearVelocity) ? 0.0f : m_linear_velocity.length2(); m_bitLocalFlag.ZeroAngularVelocity = MT_fuzzyZero(m_angular_velocity); - m_angular_length2 = (m_bitLocalFlag.ZeroAngularVelocity) ? 0.0 : m_angular_velocity.length2(); + m_angular_length2 = (m_bitLocalFlag.ZeroAngularVelocity) ? 0.0f : m_angular_velocity.length2(); } virtual bool Update(); diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index 456f5f8af3b..239bfde4c98 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -302,7 +302,7 @@ void KX_ObstacleSimulation::DrawObstacles() if (!m_enableVisualization) return; static const MT_Vector3 bluecolor(0,0,1); - static const MT_Vector3 normal(0.0, 0.0, 1.0); + static const MT_Vector3 normal(0.0f, 0.0f, 1.0f); static const int SECTORS_NUM = 32; for (size_t i=0; i<m_obstacles.size(); i++) { @@ -362,7 +362,7 @@ static bool filterObstacle(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM //filter obstacles by position MT_Point3 p = nearestPointToObstacle(activeObst->m_pos, otherObst); - if ( fabs(activeObst->m_pos.z() - p.z()) > levelHeight) + if ( fabsf(activeObst->m_pos.z() - p.z()) > levelHeight) return false; return true; @@ -459,14 +459,14 @@ void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMes { // Calculate sample velocity const float ndir = ((float)iter/(float)m_maxSamples) - aoff; - const float dir = odir+ndir*M_PI*2; + const float dir = odir+ndir*(float)M_PI*2.0f; MT_Vector2 svel; svel.x() = cosf(dir) * vmax; svel.y() = sinf(dir) * vmax; // Find min time of impact and exit amongst all obstacles. float tmin = m_maxToi; - float tmine = 0; + float tmine = 0.0f; for (int i = 0; i < nobs; ++i) { KX_Obstacle* ob = m_obstacles[i]; diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp index d2468d0317d..bcaa1e60e92 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp @@ -39,12 +39,12 @@ void KX_OrientationInterpolator::Execute(float currentTime) const MT_Vector3 eul(m_ipos[0]->GetValue(currentTime), m_ipos[1]->GetValue(currentTime), m_ipos[2]->GetValue(currentTime)); - MT_Scalar ci = cos(eul[0]); - MT_Scalar cj = cos(eul[1]); - MT_Scalar ch = cos(eul[2]); - MT_Scalar si = sin(eul[0]); - MT_Scalar sj = sin(eul[1]); - MT_Scalar sh = sin(eul[2]); + MT_Scalar ci = cosf(eul[0]); + MT_Scalar cj = cosf(eul[1]); + MT_Scalar ch = cosf(eul[2]); + MT_Scalar si = sinf(eul[0]); + MT_Scalar sj = sinf(eul[1]); + MT_Scalar sh = sinf(eul[2]); MT_Scalar cc = ci*ch; MT_Scalar cs = ci*sh; MT_Scalar sc = si*ch; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index d1119b05b5d..3ac5d884c9a 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -198,8 +198,12 @@ void KX_RasterizerDrawDebugCircle(const MT_Vector3& center, const MT_Scalar radi #ifdef WITH_PYTHON -static PyObject *gp_OrigPythonSysPath= NULL; -static PyObject *gp_OrigPythonSysModules= NULL; + +static struct { + PyObject *path; + PyObject *meta_path; + PyObject *modules; +} gp_sys_backup = {NULL}; /* Macro for building the keyboard translation */ //#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyLong_FromLong(SCA_IInputDevice::KX_##name)) @@ -564,6 +568,64 @@ static PyObject *gPyGetAverageFrameRate(PyObject *) return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate()); } +static PyObject *gPyGetUseExternalClock(PyObject *) +{ + return PyBool_FromLong(gp_KetsjiEngine->GetUseExternalClock()); +} + +static PyObject *gPySetUseExternalClock(PyObject *, PyObject *args) +{ + bool bUseExternalClock; + + if (!PyArg_ParseTuple(args, "p:setUseExternalClock", &bUseExternalClock)) + return NULL; + + gp_KetsjiEngine->SetUseExternalClock(bUseExternalClock); + Py_RETURN_NONE; +} + +static PyObject *gPyGetClockTime(PyObject *) +{ + return PyFloat_FromDouble(gp_KetsjiEngine->GetClockTime()); +} + +static PyObject *gPySetClockTime(PyObject *, PyObject *args) +{ + double externalClockTime; + + if (!PyArg_ParseTuple(args, "d:setClockTime", &externalClockTime)) + return NULL; + + gp_KetsjiEngine->SetClockTime(externalClockTime); + Py_RETURN_NONE; +} + +static PyObject *gPyGetFrameTime(PyObject *) +{ + return PyFloat_FromDouble(gp_KetsjiEngine->GetFrameTime()); +} + +static PyObject *gPyGetRealTime(PyObject *) +{ + return PyFloat_FromDouble(gp_KetsjiEngine->GetRealTime()); +} + +static PyObject *gPyGetTimeScale(PyObject *) +{ + return PyFloat_FromDouble(gp_KetsjiEngine->GetTimeScale()); +} + +static PyObject *gPySetTimeScale(PyObject *, PyObject *args) +{ + double time_scale; + + if (!PyArg_ParseTuple(args, "d:setTimeScale", &time_scale)) + return NULL; + + gp_KetsjiEngine->SetTimeScale(time_scale); + Py_RETURN_NONE; +} + static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args) { char cpath[sizeof(gp_GamePythonPath)]; @@ -663,71 +725,10 @@ static PyObject *pyPrintStats(PyObject *,PyObject *,PyObject *) static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) { -#define pprint(x) std::cout << x << std::endl; - bool count=0; - bool support=0; - pprint("Supported Extensions..."); - pprint(" GL_ARB_shader_objects supported? "<< (GLEW_ARB_shader_objects?"yes.":"no.")); - count = 1; - - support= GLEW_ARB_vertex_shader; - pprint(" GL_ARB_vertex_shader supported? "<< (support?"yes.":"no.")); - count = 1; - if (support) { - pprint(" ----------Details----------"); - int max=0; - glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, (GLint*)&max); - pprint(" Max uniform components." << max); - - glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, (GLint*)&max); - pprint(" Max varying floats." << max); - - glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max); - pprint(" Max vertex texture units." << max); - - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max); - pprint(" Max combined texture units." << max); - pprint(""); - } - - support=GLEW_ARB_fragment_shader; - pprint(" GL_ARB_fragment_shader supported? "<< (support?"yes.":"no.")); - count = 1; - if (support) { - pprint(" ----------Details----------"); - int max=0; - glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, (GLint*)&max); - pprint(" Max uniform components." << max); - pprint(""); - } - - support = GLEW_ARB_texture_cube_map; - pprint(" GL_ARB_texture_cube_map supported? "<< (support?"yes.":"no.")); - count = 1; - if (support) { - pprint(" ----------Details----------"); - int size=0; - glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, (GLint*)&size); - pprint(" Max cubemap size." << size); - pprint(""); - } - - support = GLEW_ARB_multitexture; - count = 1; - pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no.")); - if (support) { - pprint(" ----------Details----------"); - int units=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units); - pprint(" Max texture units available. " << units); - pprint(""); - } - - pprint(" GL_ARB_texture_env_combine supported? "<< (GLEW_ARB_texture_env_combine?"yes.":"no.")); - count = 1; - - if (!count) - pprint("No extenstions are used in this build"); + if (gp_Rasterizer) + gp_Rasterizer->PrintHardwareInfo(); + else + printf("Warning: no rasterizer detected for PrintGLInfo!\n"); Py_RETURN_NONE; } @@ -926,7 +927,19 @@ static struct PyMethodDef game_methods[] = { {"setExitKey", (PyCFunction) gPySetExitKey, METH_VARARGS, (const char *)"Sets the key used to exit the game engine"}, {"setRender", (PyCFunction) gPySetRender, METH_VARARGS, (const char *)"Set the global render flag"}, {"getRender", (PyCFunction) gPyGetRender, METH_NOARGS, (const char *)"get the global render flag value"}, + {"getUseExternalClock", (PyCFunction) gPyGetUseExternalClock, METH_NOARGS, (const char *)"Get if we use the time provided by an external clock"}, + {"setUseExternalClock", (PyCFunction) gPySetUseExternalClock, METH_VARARGS, (const char *)"Set if we use the time provided by an external clock"}, + {"getClockTime", (PyCFunction) gPyGetClockTime, METH_NOARGS, (const char *)"Get the last BGE render time. " + "The BGE render time is the simulated time corresponding to the next scene that will be renderered"}, + {"setClockTime", (PyCFunction) gPySetClockTime, METH_VARARGS, (const char *)"Set the BGE render time. " + "The BGE render time is the simulated time corresponding to the next scene that will be rendered"}, + {"getFrameTime", (PyCFunction) gPyGetFrameTime, METH_NOARGS, (const char *)"Get the BGE last frametime. " + "The BGE frame time is the simulated time corresponding to the last call of the logic system"}, + {"getRealTime", (PyCFunction) gPyGetRealTime, METH_NOARGS, (const char *)"Get the real system time. " + "The real-time corresponds to the system time" }, {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (const char *)"Gets the estimated average frame rate"}, + {"getTimeScale", (PyCFunction) gPyGetTimeScale, METH_NOARGS, (const char *)"Get the time multiplier"}, + {"setTimeScale", (PyCFunction) gPySetTimeScale, METH_VARARGS, (const char *)"Set the time multiplier"}, {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (const char *)"Gets a list of blend files in the same directory as the current blend file"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"}, {"PrintMemInfo", (PyCFunction)pyPrintStats, METH_NOARGS, (const char *)"Print engine statistics"}, @@ -2067,11 +2080,12 @@ PyMODINIT_FUNC initGameLogicPythonBinding() return m; } -/* Explanation of +/** + * Explanation of * - * - backupPySysObjects() : stores sys.path in gp_OrigPythonSysPath - * - initPySysObjects(main) : initializes the blendfile and library paths - * - restorePySysObjects() : restores sys.path from gp_OrigPythonSysPath + * - backupPySysObjects() : stores sys.path in #gp_sys_backup + * - initPySysObjects(main) : initializes the blendfile and library paths + * - restorePySysObjects() : restores sys.path from #gp_sys_backup * * These exist so the current blend dir "//" can always be used to import modules from. * the reason we need a few functions for this is that python is not only used by the game engine @@ -2088,16 +2102,21 @@ PyMODINIT_FUNC initGameLogicPythonBinding() */ static void backupPySysObjects(void) { - PyObject *sys_path= PySys_GetObject("path"); /* should never fail */ - PyObject *sys_mods= PySys_GetObject("modules"); /* should never fail */ + PyObject *sys_path = PySys_GetObject("path"); + PyObject *sys_meta_path = PySys_GetObject("meta_path"); + PyObject *sys_mods = PySys_GetObject("modules"); /* paths */ - Py_XDECREF(gp_OrigPythonSysPath); /* just in case its set */ - gp_OrigPythonSysPath = PyList_GetSlice(sys_path, 0, INT_MAX); /* copy the list */ + Py_XDECREF(gp_sys_backup.path); /* just in case its set */ + gp_sys_backup.path = PyList_GetSlice(sys_path, 0, INT_MAX); /* copy the list */ + /* meta_paths */ + Py_XDECREF(gp_sys_backup.meta_path); /* just in case its set */ + gp_sys_backup.meta_path = PyList_GetSlice(sys_meta_path, 0, INT_MAX); /* copy the list */ + /* modules */ - Py_XDECREF(gp_OrigPythonSysModules); /* just in case its set */ - gp_OrigPythonSysModules = PyDict_Copy(sys_mods); /* copy the list */ + Py_XDECREF(gp_sys_backup.modules); /* just in case its set */ + gp_sys_backup.modules = PyDict_Copy(sys_mods); /* copy the dict */ } @@ -2127,15 +2146,17 @@ static void initPySysObjects__append(PyObject *sys_path, const char *filename) } static void initPySysObjects(Main *maggie) { - PyObject *sys_path= PySys_GetObject("path"); /* should never fail */ + PyObject *sys_path = PySys_GetObject("path"); + PyObject *sys_meta_path = PySys_GetObject("meta_path"); - if (gp_OrigPythonSysPath==NULL) { + if (gp_sys_backup.path == NULL) { /* backup */ backupPySysObjects(); } else { /* get the original sys path when the BGE started */ - PyList_SetSlice(sys_path, 0, INT_MAX, gp_OrigPythonSysPath); + PyList_SetSlice(sys_path, 0, INT_MAX, gp_sys_backup.path); + PyList_SetSlice(sys_meta_path, 0, INT_MAX, gp_sys_backup.meta_path); } Library *lib= (Library *)maggie->library.first; @@ -2155,22 +2176,30 @@ static void initPySysObjects(Main *maggie) static void restorePySysObjects(void) { - if (gp_OrigPythonSysPath==NULL) + if (gp_sys_backup.path == NULL) { return; - - PyObject *sys_path= PySys_GetObject("path"); /* should never fail */ - PyObject *sys_mods= PySys_GetObject("modules"); /* should never fail */ + } + + /* will never fail */ + PyObject *sys_path = PySys_GetObject("path"); + PyObject *sys_meta_path = PySys_GetObject("meta_path"); + PyObject *sys_mods = PySys_GetObject("modules"); /* paths */ - PyList_SetSlice(sys_path, 0, INT_MAX, gp_OrigPythonSysPath); - Py_DECREF(gp_OrigPythonSysPath); - gp_OrigPythonSysPath= NULL; + PyList_SetSlice(sys_path, 0, INT_MAX, gp_sys_backup.path); + Py_DECREF(gp_sys_backup.path); + gp_sys_backup.path = NULL; + + /* meta_path */ + PyList_SetSlice(sys_meta_path, 0, INT_MAX, gp_sys_backup.meta_path); + Py_DECREF(gp_sys_backup.meta_path); + gp_sys_backup.meta_path = NULL; /* modules */ PyDict_Clear(sys_mods); - PyDict_Update(sys_mods, gp_OrigPythonSysModules); - Py_DECREF(gp_OrigPythonSysModules); - gp_OrigPythonSysModules= NULL; + PyDict_Update(sys_mods, gp_sys_backup.modules); + Py_DECREF(gp_sys_backup.modules); + gp_sys_backup.modules = NULL; // fprintf(stderr, "\nRestore Path: %d ", PyList_GET_SIZE(sys_path)); diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 732bcdc3773..861e3f70296 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -104,42 +104,42 @@ void KX_RadarSensor::SynchronizeTransform() { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_Y_AXIS: // +Y Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_Z_AXIS: // +Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_NEG_X_AXIS: // -X Axis { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_NEG_Y_AXIS: // -Y Axis { //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); //trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_NEG_Z_AXIS: // -Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; default: @@ -154,7 +154,7 @@ void KX_RadarSensor::SynchronizeTransform() m_cone_origin[1] = temp[1]; m_cone_origin[2] = temp[2]; - temp = trans(MT_Point3(0, -m_coneheight/2.0, 0)); + temp = trans(MT_Point3(0, -m_coneheight/2.0f, 0)); m_cone_target[0] = temp[0]; m_cone_target[1] = temp[1]; m_cone_target[2] = temp[2]; diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index 333e7b57d67..478019c6304 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -103,11 +103,11 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_ // but it would require some change in Bullet. prevpoint = callback.m_hitPoint; /* We add 0.001 of fudge, so that if the margin && radius == 0.0, we don't endless loop. */ - MT_Scalar marg = 0.001 + hit_controller->GetMargin(); + MT_Scalar marg = 0.001f + hit_controller->GetMargin(); marg *= 2.f; /* Calculate the other side of this object */ MT_Scalar h = MT_abs(todir.dot(callback.m_hitNormal)); - if (h <= 0.01) + if (h <= 0.01f) // the normal is almost orthogonal to the ray direction, cannot compute the other side break; marg /= h; diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index 96e1cc29de3..a4220424c6f 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -73,7 +73,7 @@ PyMethodDef KX_SCA_DynamicActuator::Methods[] = { PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = { KX_PYATTRIBUTE_SHORT_RW("mode",0,4,false,KX_SCA_DynamicActuator,m_dyn_operation), - KX_PYATTRIBUTE_FLOAT_RW("mass",0.0,FLT_MAX,KX_SCA_DynamicActuator,m_setmass), + KX_PYATTRIBUTE_FLOAT_RW("mass",0.0f,FLT_MAX,KX_SCA_DynamicActuator,m_setmass), { NULL } //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp index 19b9d13087d..5a13cf5440d 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp @@ -89,7 +89,7 @@ UpdateChildCoordinates( { // Get the child's transform, and the bone matrix. MT_Matrix4x4 child_transform ( - MT_Transform(child_pos + MT_Vector3(0.0, armature->GetBoneLength(m_bone), 0.0), + MT_Transform(child_pos + MT_Vector3(0.0f, armature->GetBoneLength(m_bone), 0.0f), child_rotation.scaled( child_scale[0], child_scale[1], @@ -107,7 +107,7 @@ UpdateChildCoordinates( child_w_rotation.setValue(child_transform[0][0], child_transform[0][1], child_transform[0][2], child_transform[1][0], child_transform[1][1], child_transform[1][2], child_transform[2][0], child_transform[2][1], child_transform[2][2]); - child_w_rotation.scale(1.0/child_w_scale[0], 1.0/child_w_scale[1], 1.0/child_w_scale[2]); + child_w_rotation.scale(1.0f/child_w_scale[0], 1.0f/child_w_scale[1], 1.0f/child_w_scale[2]); child_w_pos = MT_Point3(child_transform[0][3], child_transform[1][3], child_transform[2][3]); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 52a51032c0f..149f0fb0168 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -899,7 +899,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, m_tempObjectList->Add(replica->AddRef()); // this convert the life from frames to sort-of seconds, hard coded 0.02 that assumes we have 50 frames per second // if you change this value, make sure you change it in KX_GameObject::pyattr_get_life property too - CValue *fval = new CFloatValue(lifespan*0.02); + CValue *fval = new CFloatValue(lifespan*0.02f); replica->SetProperty("::timebomb",fval); fval->Release(); } @@ -1558,9 +1558,9 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int planes[5].setValue(cplanes[3].getValue()); // bottom CullingInfo info(layer); - double mvmat[16] = {0}; + float mvmat[16] = {0}; cam->GetModelviewMatrix().getValue(mvmat); - double pmat[16] = {0}; + float pmat[16] = {0}; cam->GetProjectionMatrix().getValue(pmat); dbvt_culling = m_physicsEnvironment->CullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res, @@ -1589,7 +1589,7 @@ void KX_Scene::LogicBeginFrame(double curtime) if (propval) { - float timeleft = propval->GetNumber() - 1.0/KX_KetsjiEngine::GetTicRate(); + float timeleft = (float)(propval->GetNumber() - 1.0/KX_KetsjiEngine::GetTicRate()); if (timeleft > 0) { @@ -1828,9 +1828,9 @@ void KX_Scene::UpdateObjectActivity(void) * Manhattan distance. */ MT_Point3 obpos = ob->NodeGetWorldPosition(); - if ((fabs(camloc[0] - obpos[0]) > m_activity_box_radius) || - (fabs(camloc[1] - obpos[1]) > m_activity_box_radius) || - (fabs(camloc[2] - obpos[2]) > m_activity_box_radius) ) + if ((fabsf(camloc[0] - obpos[0]) > m_activity_box_radius) || + (fabsf(camloc[1] - obpos[1]) > m_activity_box_radius) || + (fabsf(camloc[2] - obpos[2]) > m_activity_box_radius) ) { ob->Suspend(); } @@ -1844,8 +1844,8 @@ void KX_Scene::UpdateObjectActivity(void) void KX_Scene::SetActivityCullingRadius(float f) { - if (f < 0.5) - f = 0.5; + if (f < 0.5f) + f = 0.5f; m_activity_box_radius = f; } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 64381dca12e..6d8ae8a321b 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -93,7 +93,7 @@ class KX_ObstacleSimulation; #endif /* for ID freeing */ -#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->flag & LIB_DOIT)) +#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT)) /** * The KX_Scene holds all data for an independent scene. It relates diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index f6f09dd3bda..1c42d65ae75 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -379,7 +379,7 @@ PyObject *KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_P { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); const char* prop = attrdef->m_name; - float result_value = 0.0; + float result_value = 0.0f; if (!strcmp(prop, "volume_maximum")) { result_value = actuator->m_3d.max_gain; @@ -416,7 +416,7 @@ PyObject *KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_P PyObject *KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); - float position = 0.0; + float position = 0.0f; if (actuator->m_handle) position = AUD_Handle_getPosition(actuator->m_handle); @@ -459,7 +459,7 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); const char* prop = attrdef->m_name; - float prop_value = 0.0; + float prop_value = 0.0f; if (!PyArg_Parse(value, "f", &prop_value)) return PY_SET_ATTR_FAIL; @@ -519,7 +519,7 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); - float position = 1.0; + float position = 1.0f; if (!PyArg_Parse(value, "f", &position)) return PY_SET_ATTR_FAIL; @@ -530,7 +530,7 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - float gain = 1.0; + float gain = 1.0f; KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); if (!PyArg_Parse(value, "f", &gain)) return PY_SET_ATTR_FAIL; @@ -544,7 +544,7 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - float pitch = 1.0; + float pitch = 1.0f; KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); if (!PyArg_Parse(value, "f", &pitch)) return PY_SET_ATTR_FAIL; diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.cpp b/source/gameengine/Ketsji/KX_SteeringActuator.cpp index cd2cd2bae0b..af2a2b30b84 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.cpp +++ b/source/gameengine/Ketsji/KX_SteeringActuator.cpp @@ -169,8 +169,8 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) if (m_posevent && !m_isActive) { - delta = 0; - m_pathUpdateTime = -1; + delta = 0.0; + m_pathUpdateTime = -1.0; m_updateTime = curtime; m_isActive = true; } @@ -191,8 +191,8 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) const MT_Point3& targpos = m_target->NodeGetWorldPosition(); MT_Vector3 vectotarg = targpos - mypos; MT_Vector3 vectotarg2d = vectotarg; - vectotarg2d.z() = 0; - m_steerVec = MT_Vector3(0, 0, 0); + vectotarg2d.z() = 0.0f; + m_steerVec = MT_Vector3(0.0f, 0.0f, 0.0f); bool apply_steerforce = false; bool terminate = true; @@ -220,10 +220,10 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) { terminate = false; - static const MT_Scalar WAYPOINT_RADIUS(0.25); + static const MT_Scalar WAYPOINT_RADIUS(0.25f); if (m_pathUpdateTime<0 || (m_pathUpdatePeriod>=0 && - curtime - m_pathUpdateTime>((double)m_pathUpdatePeriod/1000))) + curtime - m_pathUpdateTime>((double)m_pathUpdatePeriod/1000.0))) { m_pathUpdateTime = curtime; m_pathLen = m_navmesh->FindPath(mypos, targpos, m_path, MAX_PATH_LENGTH); @@ -252,7 +252,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) if (m_enableVisualization) { //debug draw - static const MT_Vector3 PATH_COLOR(1,0,0); + static const MT_Vector3 PATH_COLOR(1.0f,0.0f,0.0f); m_navmesh->DrawPath(m_path, m_pathLen, PATH_COLOR); } } @@ -274,11 +274,11 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) if (m_simulation && m_obstacle /*&& !newvel.fuzzyZero()*/) { if (m_enableVisualization) - KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(1.0, 0.0, 0.0)); + KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(1.0f, 0.0f, 0.0f)); m_simulation->AdjustObstacleVelocity(m_obstacle, m_mode!=KX_STEERING_PATHFOLLOWING ? m_navmesh : NULL, - newvel, m_acceleration*delta, m_turnspeed/180.0f*M_PI*delta); + newvel, m_acceleration*(float)delta, m_turnspeed/(180.0f*(float)(M_PI*delta))); if (m_enableVisualization) - KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(0.0, 1.0, 0.0)); + KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(0.0f, 1.0f, 0.0f)); } HandleActorFace(newvel); diff --git a/source/gameengine/Ketsji/KX_TimeLogger.cpp b/source/gameengine/Ketsji/KX_TimeLogger.cpp index 1a0d3d28d4c..12106245c4d 100644 --- a/source/gameengine/Ketsji/KX_TimeLogger.cpp +++ b/source/gameengine/Ketsji/KX_TimeLogger.cpp @@ -109,7 +109,7 @@ double KX_TimeLogger::GetAverage(void) const for (unsigned int i = 1; i < numMeasurements; i++) { avg += m_measurements[i]; } - avg /= (float)numMeasurements - 1; + avg /= (double)numMeasurements - 1.0; } return avg; diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index eb774960d41..7f167652464 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -235,5 +235,12 @@ KX_TouchEventManager::NewCollision::NewCollision(const NewCollision &to_copy) bool KX_TouchEventManager::NewCollision::operator<(const NewCollision &other) const { - return first < other.first || second < other.second || colldata < other.colldata; + //see strict weak ordering: https://support.microsoft.com/en-us/kb/949171 + if (first == other.first) { + if (second == other.second) { + return colldata < other.colldata; + } + return second < other.second; + } + return first < other.first; } diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 3ed8eba759f..74902ab20ee 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -92,12 +92,12 @@ static MT_Matrix3x3 EulToMat3(float eul[3]) MT_Matrix3x3 mat; float ci, cj, ch, si, sj, sh, cc, cs, sc, ss; - ci = cos(eul[0]); - cj = cos(eul[1]); - ch = cos(eul[2]); - si = sin(eul[0]); - sj = sin(eul[1]); - sh = sin(eul[2]); + ci = cosf(eul[0]); + cj = cosf(eul[1]); + ch = cosf(eul[2]); + si = sinf(eul[0]); + sj = sinf(eul[1]); + sh = sinf(eul[2]); cc = ci*ch; cs = ci*sh; sc = si*ch; @@ -131,7 +131,7 @@ static void Mat3ToEulOld(MT_Matrix3x3 mat, float eul[3]) else { eul[0] = atan2f(-mat[2][1], mat[1][1]); eul[1] = atan2f(-mat[0][2], cy); - eul[2] = 0.0; + eul[2] = 0.0f; } } @@ -196,8 +196,8 @@ static float basis_cross(int n, int m) static MT_Matrix3x3 vectomat(MT_Vector3 vec, short axis, short upflag, short threedimup) { MT_Matrix3x3 mat; - MT_Vector3 y(MT_Scalar(0.0), MT_Scalar(1.0), MT_Scalar(0.0)); - MT_Vector3 z(MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(1.0)); /* world Z axis is the global up axis */ + MT_Vector3 y(MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f)); + MT_Vector3 z(MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f)); /* world Z axis is the global up axis */ MT_Vector3 proj; MT_Vector3 right; MT_Scalar mul; @@ -208,7 +208,7 @@ static MT_Matrix3x3 vectomat(MT_Vector3 vec, short axis, short upflag, short thr /* if 2D doesn't move the up vector */ if (!threedimup){ - vec.setValue(MT_Scalar(vec[0]), MT_Scalar(vec[1]), MT_Scalar(0.0)); + vec.setValue(MT_Scalar(vec[0]), MT_Scalar(vec[1]), MT_Scalar(0.0f)); vec = (vec - z.dot(vec)*z).safe_normalized_vec(z); } diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index cd1c9eed91b..40f4c462801 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -198,7 +198,7 @@ PyObject *KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DE KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); const unsigned char *colp = self->m_vertex->getRGBA(); MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]); - color /= 255.0; + color /= 255.0f; return PyObjectFrom(color); } @@ -321,7 +321,7 @@ int KX_VertexProxy::pyattr_set_r(void *self_v, const struct KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; - val *= 255.0; + val *= 255.0f; cp[0] = (unsigned char) val; self->m_vertex->SetRGBA(icol); self->m_mesh->SetMeshModified(true); @@ -338,7 +338,7 @@ int KX_VertexProxy::pyattr_set_g(void *self_v, const struct KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; - val *= 255.0; + val *= 255.0f; cp[1] = (unsigned char) val; self->m_vertex->SetRGBA(icol); self->m_mesh->SetMeshModified(true); @@ -355,7 +355,7 @@ int KX_VertexProxy::pyattr_set_b(void *self_v, const struct KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; - val *= 255.0; + val *= 255.0f; cp[2] = (unsigned char) val; self->m_vertex->SetRGBA(icol); self->m_mesh->SetMeshModified(true); @@ -372,7 +372,7 @@ int KX_VertexProxy::pyattr_set_a(void *self_v, const struct KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; - val *= 255.0; + val *= 255.0f; cp[3] = (unsigned char) val; self->m_vertex->SetRGBA(icol); self->m_mesh->SetMeshModified(true); diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript deleted file mode 100644 index d8dfd3d9bca..00000000000 --- a/source/gameengine/Ketsji/SConscript +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -import sys - -Import ('env') - -sources = env.Glob('*.cpp') -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -incs = [ - '.', - '#intern/container', - '#intern/guardedalloc', - '#intern/string', - '#source/blender', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - '#intern/moto/include', - '#source/blender/blenfont', - '#source/blender/blenkernel', - '#source/blender/blenlib', - '#source/blender/gpu', - '#source/blender/imbuf', - '#source/blender/makesdna', - '#source/blender/makesrna', - '#source/blender/misc', - '#source/blender/python', - '#source/gameengine/BlenderRoutines', - '#source/gameengine/Converter', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Ketsji', - '#source/gameengine/Network', - '#source/gameengine/Rasterizer', - '#source/gameengine/SceneGraph', - '#extern/recastnavigation/Detour/Include', - '#extern/recastnavigation/Recast/Include', - '#source/blender/editors/include', - # Only for bpy_internal_import.h, be very careful - '#source/blender/python/generic', - # Only for mathutils, be very careful - '#source/blender/python/mathutils', - '#source/gameengine/Ketsji/KXNetwork', - '#source/gameengine/Physics/Dummy', - '#source/gameengine/Physics/common', - '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - ] -incs = ' '.join(incs) - -incs += ' ' + env['BF_BULLET_INC'] -incs += ' ' + env['BF_OPENGL_INC'] -incs += ' ' + env['BF_BOOST_INC'] - -if env['WITH_BF_SDL']: - incs += ' ' + env['BF_SDL_INC'] - defs.append('WITH_SDL') - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -if env['WITH_BF_AUDASPACE']: - defs += env['BF_AUDASPACE_DEF'] - incs += ' ' + env['BF_AUDASPACE_C_INC'] - incs += ' ' + env['BF_AUDASPACE_PY_INC'] - -if env['WITH_BF_FFMPEG']: - defs.append('WITH_FFMPEG') - -if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'): - if env['BF_DEBUG']: - defs.append('_DEBUG') # for Python - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - -if env['WITH_BF_BULLET']: - defs.append('WITH_BULLET') - incs += ' #source/gameengine/Physics/Bullet' - -if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): - incs += ' ' + env['BF_PTHREADS_INC'] - -env.BlenderLib ( 'ge_logic_ketsji', sources, Split(incs), defs, libtype=['core','player'], priority=[320,45], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Network/LoopBackNetwork/SConscript b/source/gameengine/Network/LoopBackNetwork/SConscript deleted file mode 100644 index 01352fbe732..00000000000 --- a/source/gameengine/Network/LoopBackNetwork/SConscript +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = [ - 'NG_LoopBackNetworkDeviceInterface.cpp', - ] - -incs = [ - '.', - '#intern/container', - '#intern/string', - '#source/gameengine/Network', - ] - -env.BlenderLib('ge_logic_loopbacknetwork', sources, incs, defines=[], libtype=['core', 'player'], priority=[400, 135]) diff --git a/source/gameengine/Network/SConscript b/source/gameengine/Network/SConscript deleted file mode 100644 index feb14e29552..00000000000 --- a/source/gameengine/Network/SConscript +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('*.cpp') #'NG_NetworkMessage.cpp NG_NetworkObject.cpp NG_NetworkScene.cpp' - -incs = [ - '.', - '../../blender/blenlib', - '#intern/container', - '#intern/string', - '#intern/moto/include', - ] - -defs = [] - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - incs.append('#intern/guardedalloc') - -env.BlenderLib('ge_logic_ngnetwork', sources, incs, defs, libtype=['core', 'player'], priority=[400, 130]) diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp index fdafc4e507d..470a5431843 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp @@ -86,15 +86,15 @@ void CcdGraphicController::GetAabb(btVector3& aabbMin, btVector3& aabbMax) btVector3 tmpAabbMin = m_localAabbMin * scale; btVector3 tmpAabbMax = m_localAabbMax * scale; - localAabbMin[0] = (scale.getX() >= 0.0) ? tmpAabbMin[0] : tmpAabbMax[0]; - localAabbMin[1] = (scale.getY() >= 0.0) ? tmpAabbMin[1] : tmpAabbMax[1]; - localAabbMin[2] = (scale.getZ() >= 0.0) ? tmpAabbMin[2] : tmpAabbMax[2]; - localAabbMax[0] = (scale.getX() <= 0.0) ? tmpAabbMin[0] : tmpAabbMax[0]; - localAabbMax[1] = (scale.getY() <= 0.0) ? tmpAabbMin[1] : tmpAabbMax[1]; - localAabbMax[2] = (scale.getZ() <= 0.0) ? tmpAabbMin[2] : tmpAabbMax[2]; - - btVector3 localHalfExtents = btScalar(0.5)*(localAabbMax-localAabbMin); - btVector3 localCenter = btScalar(0.5)*(localAabbMax+localAabbMin); + localAabbMin[0] = (scale.getX() >= 0.0f) ? tmpAabbMin[0] : tmpAabbMax[0]; + localAabbMin[1] = (scale.getY() >= 0.0f) ? tmpAabbMin[1] : tmpAabbMax[1]; + localAabbMin[2] = (scale.getZ() >= 0.0f) ? tmpAabbMin[2] : tmpAabbMax[2]; + localAabbMax[0] = (scale.getX() <= 0.0f) ? tmpAabbMin[0] : tmpAabbMax[0]; + localAabbMax[1] = (scale.getY() <= 0.0f) ? tmpAabbMin[1] : tmpAabbMax[1]; + localAabbMax[2] = (scale.getZ() <= 0.0f) ? tmpAabbMin[2] : tmpAabbMax[2]; + + btVector3 localHalfExtents = btScalar(0.5f)*(localAabbMax-localAabbMin); + btVector3 localCenter = btScalar(0.5f)*(localAabbMax+localAabbMin); btMatrix3x3 abs_b = rot.absolute(); btVector3 center = rot*localCenter + pos; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 7917f47019d..89806d80ea9 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -157,7 +157,7 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) m_savedCollisionFlags = 0; m_savedCollisionFilterGroup = 0; m_savedCollisionFilterMask = 0; - m_savedMass = 0.0; + m_savedMass = 0.0f; m_savedDyna = false; m_suspended = false; @@ -280,7 +280,7 @@ bool CcdPhysicsController::CreateSoftbody() rbci.m_friction = m_cci.m_friction; rbci.m_restitution = m_cci.m_restitution; - btVector3 p(0,0,0);// = getOrigin(); + btVector3 p(0.0f,0.0f,0.0f);// = getOrigin(); //btSoftBody* psb=btSoftBodyHelpers::CreateRope(worldInfo, btVector3(-10,0,i*0.25),btVector3(10,0,i*0.25), 16,1+2); btSoftBody* psb = 0; btSoftBodyWorldInfo& worldInfo = m_cci.m_physicsEnv->GetDynamicsWorld()->getWorldInfo(); @@ -1095,7 +1095,7 @@ void CcdPhysicsController::SuspendDynamics(bool ghost) m_savedCollisionFilterMask = handle->m_collisionFilterMask; m_suspended = true; GetPhysicsEnvironment()->UpdateCcdPhysicsController(this, - 0.0, + 0.0f, btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)), btBroadphaseProxy::StaticFilter, btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter); @@ -1561,9 +1561,9 @@ void CcdPhysicsController::AddCompoundChild(PHY_IPhysicsController* child) rootBody->getMotionState()->getWorldTransform(rootTrans); childBody->getMotionState()->getWorldTransform(childTrans); btVector3 rootScale = rootShape->getLocalScaling(); - rootScale[0] = 1.0/rootScale[0]; - rootScale[1] = 1.0/rootScale[1]; - rootScale[2] = 1.0/rootScale[2]; + rootScale[0] = 1.0f/rootScale[0]; + rootScale[1] = 1.0f/rootScale[1]; + rootScale[2] = 1.0f/rootScale[2]; // relative scale = child_scale/parent_scale btVector3 relativeScale = childShape->getLocalScaling()*rootScale; btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose(); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index a0b04736bdf..58ea5e2e390 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -72,8 +72,8 @@ public: CcdShapeConstructionInfo() : m_shapeType(PHY_SHAPE_NONE), - m_radius(1.0), - m_height(1.0), + m_radius(1.0f), + m_height(1.0f), m_halfExtend(0.f,0.f,0.f), m_childScale(1.0f,1.0f,1.0f), m_userData(NULL), diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index d7b043661a0..72c96668fe7 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -598,7 +598,7 @@ void CcdPhysicsEnvironment::UpdateCcdPhysicsController(CcdPhysicsController* ctr btCollisionObject* obj = ctrl->GetCollisionObject(); if (obj) { - btVector3 inertia(0.0,0.0,0.0); + btVector3 inertia(0.0f,0.0f,0.0f); m_dynamicsWorld->removeCollisionObject(obj); obj->setCollisionFlags(newCollisionFlags); if (body) @@ -861,7 +861,7 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) lspot -= hit_object->getCenterOfMassPosition(); btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot); btScalar rel_vel_ray = ray_dir.dot(rel_vel); - btScalar spring_extent = 1.0 - distance / hitObjShapeProps.m_fh_distance; + btScalar spring_extent = 1.0f - distance / hitObjShapeProps.m_fh_distance; btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring; btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping; @@ -889,7 +889,7 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) if (rel_vel_lateral > SIMD_EPSILON) { btScalar friction_factor = hit_object->getFriction();//cl_object->getFriction(); - btScalar max_friction = friction_factor * btMax(btScalar(0.0), i_spring); + btScalar max_friction = friction_factor * btMax(btScalar(0.0f), i_spring); btScalar rel_mom_lateral = rel_vel_lateral / cl_object->getInvMass(); @@ -1472,7 +1472,7 @@ struct OcclusionBuffer m[15] = btScalar(m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]); } - void setup(int size, const int *view, double modelview[16], double projection[16]) + void setup(int size, const int *view, float modelview[16], float projection[16]) { m_initialized = false; m_occlusion = false; @@ -1519,7 +1519,7 @@ struct OcclusionBuffer m_occlusion = false; } - void SetModelMatrix(double *fl) + void SetModelMatrix(float *fl) { CMmat4mul(m_mtc,m_wtc,fl); if (!m_initialized) { @@ -1969,7 +1969,7 @@ struct DbvtCullingCallback : btDbvt::ICollide KX_GameObject* gameobj = KX_GameObject::GetClientObject(info); if (gameobj && gameobj->GetOccluder()) { - double* fl = gameobj->GetOpenGLMatrixPtr()->getPointer(); + float *fl = gameobj->GetOpenGLMatrixPtr()->getPointer(); // this will create the occlusion buffer if not already done // and compute the transformation from model local space to clip space m_ocb->SetModelMatrix(fl); @@ -2010,7 +2010,7 @@ struct DbvtCullingCallback : btDbvt::ICollide }; static OcclusionBuffer gOcb; -bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) +bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16]) { if (!m_cullingTree) return false; @@ -2803,7 +2803,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btTransform frameInB; btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z); - if (axis1.length() == 0.0) + if (axis1.length() == 0.0f) { btPlaneSpace1( axisInA, axis1, axis2 ); } @@ -2877,7 +2877,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btTransform frameInB; btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z); - if (axis1.length() == 0.0) + if (axis1.length() == 0.0f) { btPlaneSpace1( axisInA, axis1, axis2 ); } @@ -2955,7 +2955,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btTransform frameInB; btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z); - if (axis1.length() == 0.0) + if (axis1.length() == 0.0f) { btPlaneSpace1( axisInA, axis1, axis2 ); } @@ -2984,7 +2984,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl btTransform frameInB; btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z); - if (axis1.length() == 0.0) + if (axis1.length() == 0.0f) { btPlaneSpace1( axisInA, axis1, axis2 ); } @@ -3149,7 +3149,7 @@ struct BlenderDebugDraw : public btIDebugDraw virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color) { drawLine(PointOnB, PointOnB + normalOnB, color); - drawSphere(PointOnB, 0.1, color); + drawSphere(PointOnB, 0.1f, color); } virtual void setDebugMode(int debugMode) @@ -3289,7 +3289,7 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject ci.m_margin = 0.f; ci.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT; - ci.m_soft_linStiff = 0.5; + ci.m_soft_linStiff = 0.5f; ci.m_soft_angStiff = 1.f; /* angular stiffness 0..1 */ ci.m_soft_volume = 1.f; /* volume preservation 0..1 */ @@ -3300,7 +3300,7 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject ci.m_soft_kSRHR_CL = 0.1f; ci.m_soft_kSKHR_CL = 1.f; - ci.m_soft_kSSHR_CL = 0.5; + ci.m_soft_kSSHR_CL = 0.5f; ci.m_soft_kSR_SPLT_CL = 0.5f; ci.m_soft_kSK_SPLT_CL = 0.5f; @@ -3358,8 +3358,8 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject BoundBox *bb= BKE_object_boundbox_get(blenderobject); if (bb==NULL) { - bounds_center[0] = bounds_center[1] = bounds_center[2] = 0.0; - bounds_extends[0] = bounds_extends[1] = bounds_extends[2] = 1.0; + bounds_center[0] = bounds_center[1] = bounds_center[2] = 0.0f; + bounds_extends[0] = bounds_extends[1] = bounds_extends[2] = 1.0f; } else { @@ -3398,7 +3398,7 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject 2.f * bounds_extends[1], 2.f * bounds_extends[2]); - shapeInfo->m_halfExtend /= 2.0; + shapeInfo->m_halfExtend /= 2.0f; shapeInfo->m_halfExtend = shapeInfo->m_halfExtend.absolute(); shapeInfo->m_shapeType = PHY_SHAPE_BOX; bm = shapeInfo->CreateBulletShape(ci.m_margin); @@ -3504,9 +3504,9 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject SG_Node* parentNode = parent->GetSGNode(); // relative transform MT_Vector3 parentScale = parentNode->GetWorldScaling(); - parentScale[0] = MT_Scalar(1.0)/parentScale[0]; - parentScale[1] = MT_Scalar(1.0)/parentScale[1]; - parentScale[2] = MT_Scalar(1.0)/parentScale[2]; + parentScale[0] = MT_Scalar(1.0f)/parentScale[0]; + parentScale[1] = MT_Scalar(1.0f)/parentScale[1]; + parentScale[2] = MT_Scalar(1.0f)/parentScale[2]; MT_Vector3 relativeScale = gameNode->GetWorldScaling() * parentScale; MT_Matrix3x3 parentInvRot = parentNode->GetWorldOrientation().transposed(); MT_Vector3 relativePos = parentInvRot*((gameNode->GetWorldPosition()-parentNode->GetWorldPosition())*parentScale); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 86f663959f1..a64d2c8f15f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -211,7 +211,7 @@ protected: btTypedConstraint* GetConstraintById(int constraintId); virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); - virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]); + virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16]); //Methods for gamelogic collision/physics callbacks diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript deleted file mode 100644 index 5c5b1fe6ea6..00000000000 --- a/source/gameengine/Physics/Bullet/SConscript +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = 'CcdPhysicsEnvironment.cpp CcdPhysicsController.cpp CcdGraphicController.cpp' - -incs = [ - '.', - '#intern/container', - '#intern/guardedalloc', - '#intern/string', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - '#intern/moto/include', - '#source/blender/blenkernel', - '#source/blender/blenlib', - '#source/blender/makesdna', - '#source/gameengine/Converter', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Ketsji', - '#source/gameengine/Rasterizer', - '#source/gameengine/SceneGraph', - '../common', - ] -incs = ' '.join(incs) - -incs += ' ' + env['BF_BULLET_INC'] - -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - -if env['WITH_BF_BULLET']: - defs.append('WITH_BULLET') - -env.BlenderLib ( 'ge_phys_bullet', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[350,50], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 929345d7161..3e9379dd60d 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -83,7 +83,7 @@ public: } virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); - virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; } + virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16]) { return false; } //gamelogic callbacks diff --git a/source/gameengine/Physics/Dummy/SConscript b/source/gameengine/Physics/Dummy/SConscript deleted file mode 100644 index 3715dcf6aed..00000000000 --- a/source/gameengine/Physics/Dummy/SConscript +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = 'DummyPhysicsEnvironment.cpp' - -incs = [ - '.', - '../common', - '../../../../intern/moto/include', - ] -incs = ' '.join(incs) - -defs = [] - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - incs += ' #intern/guardedalloc' - -env.BlenderLib ( 'ge_phys_dummy', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[350,60] ) diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index 4b8d36285be..2997048805f 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -183,7 +183,7 @@ class PHY_IPhysicsEnvironment //culling based on physical broad phase // the plane number must be set as follow: near, far, left, right, top, botton // the near plane must be the first one and must always be present, it is used to get the direction of the view - virtual bool CullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0; + virtual bool CullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, float modelview[16], float projection[16]) = 0; //Methods for gamelogic collision/physics callbacks //todo: diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 64c9b8e223c..c65fcac5161 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -31,6 +31,7 @@ set(INC ../../blender/makesdna ../../blender/blenlib ../../blender/blenkernel + ../../blender/imbuf ../../../intern/container ../../../intern/glew-mx ../../../intern/guardedalloc @@ -53,6 +54,7 @@ set(SRC RAS_Polygon.cpp RAS_TexVert.cpp RAS_texmatrix.cpp + RAS_ICanvas.cpp RAS_2DFilterManager.h RAS_BucketManager.h diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index cedc27c3b92..82b26749fd1 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -495,10 +495,10 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glBegin(GL_QUADS); glColor4f(1.f, 1.f, 1.f, 1.f); - glTexCoord2f(1.0, 1.0); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[1], canvascoord[3]); glVertex2f(1,1); - glTexCoord2f(0.0, 1.0); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[0], canvascoord[3]); glVertex2f(-1,1); - glTexCoord2f(0.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[0], canvascoord[2]); glVertex2f(-1,-1); - glTexCoord2f(1.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[1], canvascoord[2]); glVertex2f(1,-1); + glTexCoord2f(1.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[1], canvascoord[3]); glVertex2f(1.0f,1.0f); + glTexCoord2f(0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[0], canvascoord[3]); glVertex2f(-1.0f,1.0f); + glTexCoord2f(0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[0], canvascoord[2]); glVertex2f(-1.0f,-1.0f); + glTexCoord2f(1.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[1], canvascoord[2]); glVertex2f(1.0f,-1.0f); glEnd(); } } diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index f90b5959f76..d131891cb90 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -282,7 +282,7 @@ void RAS_BucketManager::OptimizeBuckets(MT_Scalar distance) { BucketList::iterator bit; - distance = 10.0; + distance = 10.0f; for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) (*bit)->Optimize(distance); diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index e2024a4a55d..bc8433afd05 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -51,10 +51,10 @@ struct RAS_CameraData int m_viewporttop; float m_focallength; - RAS_CameraData(float lens = 35.0, float scale = 6.0, float sensor_x = 32.0, float sensor_y = 18.0, short sensor_fit = 0, - float shift_x = 0.0, float shift_y = 0.0, - float clipstart = 0.1, float clipend = 5000.0, bool perspective = true, - float focallength = 3.0, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, + RAS_CameraData(float lens = 35.0f, float scale = 6.0f, float sensor_x = 32.0f, float sensor_y = 18.0f, short sensor_fit = 0, + float shift_x = 0.0f, float shift_y = 0.0f, + float clipstart = 0.1f, float clipend = 5000.0f, bool perspective = true, + float focallength = 3.0f, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, int viewportright = 0, int viewporttop = 0) : m_lens(lens), m_scale(scale), diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp index c5f15c9ad21..8b0ec22fde3 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp +++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp @@ -283,14 +283,14 @@ ComputeFrustum( switch (sensor_fit) { case RAS_SENSORFIT_HOR: { - x_scale = 1.0; + x_scale = 1.0f; y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth()); break; } case RAS_SENSORFIT_VERT: { x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight()); - y_scale = 1.0; + y_scale = 1.0f; break; } case RAS_SENSORFIT_AUTO: @@ -377,14 +377,14 @@ RAS_FramingManager:: switch (sensor_fit) { case RAS_SENSORFIT_HOR: { - x_scale = 1.0; + x_scale = 1.0f; y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth()); break; } case RAS_SENSORFIT_VERT: { x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight()); - y_scale = 1.0; + y_scale = 1.0f; break; } case RAS_SENSORFIT_AUTO: diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.cpp b/source/gameengine/Rasterizer/RAS_ICanvas.cpp new file mode 100644 index 00000000000..808d257f8f0 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_ICanvas.cpp @@ -0,0 +1,128 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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 + * of the License, or (at your option) any later version. + * + * 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, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file gameengine/Rasterizer/RAS_ICanvas.cpp + * \ingroup bgerast + */ + +#include "RAS_ICanvas.h" +#include "DNA_scene_types.h" + +#include "BKE_image.h" +#include "BKE_global.h" +#include "BKE_main.h" + +#include "BLI_task.h" +#include "BLI_path_util.h" +#include "BLI_string.h" + +#include "MEM_guardedalloc.h" + +extern "C" { +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +} + + +// Task data for saving screenshots in a different thread. +struct ScreenshotTaskData +{ + unsigned int *dumprect; + int dumpsx; + int dumpsy; + char *path; + ImageFormatData *im_format; +}; + +/** + * Function that actually performs the image compression and saving to disk of a screenshot. + * Run in a separate thread by RAS_ICanvas::save_screenshot(). + * + * @param taskdata Must point to a ScreenshotTaskData object. This function takes ownership + * of all pointers in the ScreenshotTaskData, and frees them. + */ +void save_screenshot_thread_func(TaskPool *__restrict pool, void *taskdata, int threadid); + + +RAS_ICanvas::RAS_ICanvas() +{ + m_taskscheduler = BLI_task_scheduler_create(TASK_SCHEDULER_AUTO_THREADS); + m_taskpool = BLI_task_pool_create(m_taskscheduler, NULL); +} + +RAS_ICanvas::~RAS_ICanvas() +{ + if (m_taskpool) { + BLI_task_pool_work_and_wait(m_taskpool); + BLI_task_pool_free(m_taskpool); + m_taskpool = NULL; + } + + if (m_taskscheduler) { + BLI_task_scheduler_free(m_taskscheduler); + m_taskscheduler = NULL; + } +} + + +void save_screenshot_thread_func(TaskPool *__restrict UNUSED(pool), void *taskdata, int UNUSED(threadid)) +{ + ScreenshotTaskData *task = static_cast<ScreenshotTaskData *>(taskdata); + + /* create and save imbuf */ + ImBuf *ibuf = IMB_allocImBuf(task->dumpsx, task->dumpsy, 24, 0); + ibuf->rect = task->dumprect; + + BKE_imbuf_write_as(ibuf, task->path, task->im_format, false); + + ibuf->rect = NULL; + IMB_freeImBuf(ibuf); + MEM_freeN(task->dumprect); + MEM_freeN(task->path); + MEM_freeN(task->im_format); +} + + +void RAS_ICanvas::save_screenshot(const char *filename, int dumpsx, int dumpsy, unsigned int *dumprect, + ImageFormatData * im_format) +{ + /* create file path */ + char *path = (char *)MEM_mallocN(FILE_MAX, "screenshot-path"); + BLI_strncpy(path, filename, FILE_MAX); + BLI_path_abs(path, G.main->name); + BLI_path_frame(path, m_frame, 0); + m_frame++; + BKE_image_path_ensure_ext_from_imtype(path, im_format->imtype); + + /* Save the actual file in a different thread, so that the + * game engine can keep running at full speed. */ + ScreenshotTaskData *task = (ScreenshotTaskData *)MEM_mallocN(sizeof(ScreenshotTaskData), "screenshot-data"); + task->dumprect = dumprect; + task->dumpsx = dumpsx; + task->dumpsy = dumpsy; + task->path = path; + task->im_format = im_format; + + BLI_task_pool_push(m_taskpool, + save_screenshot_thread_func, + task, + true, // free task data + TASK_PRIORITY_LOW); +} diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index 471c2c97fa1..91cc13c8f85 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -37,6 +37,9 @@ #endif class RAS_Rect; +struct TaskScheduler; +struct TaskPool; +struct ImageFormatData; /** * 2D rendering device context. The connection from 3d rendercontext to 2d surface. @@ -56,10 +59,8 @@ public: MOUSE_NORMAL }; - virtual - ~RAS_ICanvas( - ) { - } + RAS_ICanvas(); + virtual ~RAS_ICanvas(); virtual void @@ -260,7 +261,23 @@ public: protected: RAS_MouseState m_mousestate; + int m_frame; /// frame number for screenshots. + TaskScheduler *m_taskscheduler; + TaskPool *m_taskpool; + /** + * Saves screenshot data to a file. The actual compression and disk I/O is performed in + * a separate thread. + * + * @param filename name of the file, can contain "###" for sequential numbering. A copy of the string + * is made, so the pointer can be freed by the caller. + * @param dumpsx width in pixels. + * @param dumpsy height in pixels. + * @param dumprect pixel data; ownership is passed to this function, which also frees the data. + * @param im_format image format for the file; ownership is passed to this function, which also frees the data. + */ + void save_screenshot(const char *filename, int dumpsx, int dumpsy, unsigned int *dumprect, + ImageFormatData * im_format); #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_ICanvas") diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index d07b4910968..2a736aa7deb 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -62,10 +62,10 @@ void RAS_IPolyMaterial::Initialize( m_polymatid = m_newpolymatid++; m_flag = 0; m_multimode = 0; - m_shininess = 35.0; - m_specular.setValue(0.5,0.5,0.5); - m_specularity = 1.0; - m_diffuse.setValue(0.5,0.5,0.5); + m_shininess = 35.0f; + m_specular.setValue(0.5f,0.5f,0.5f); + m_specularity = 1.0f; + m_diffuse.setValue(0.5f,0.5f,0.5f); m_drawingmode = ConvertFaceMode(game, image); } @@ -85,10 +85,10 @@ RAS_IPolyMaterial::RAS_IPolyMaterial() m_flag(0), m_multimode(0) { - m_shininess = 35.0; - m_specular = MT_Vector3(0.5,0.5,0.5); - m_specularity = 1.0; - m_diffuse = MT_Vector3(0.5,0.5,0.5); + m_shininess = 35.0f; + m_specular = MT_Vector3(0.5f,0.5f,0.5f); + m_specularity = 1.0f; + m_diffuse = MT_Vector3(0.5f,0.5f,0.5f); } RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, @@ -113,10 +113,10 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, m_flag(0), m_multimode(0) { - m_shininess = 35.0; - m_specular = MT_Vector3(0.5,0.5,0.5); - m_specularity = 1.0; - m_diffuse = MT_Vector3(0.5,0.5,0.5); + m_shininess = 35.0f; + m_specular = MT_Vector3(0.5f,0.5f,0.5f); + m_specularity = 1.0f; + m_diffuse = MT_Vector3(0.5f,0.5f,0.5f); } diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 7d4151a0a3c..dc92408915b 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -281,7 +281,6 @@ public: * IndexPrimitives: Renders primitives from mesh slot. */ virtual void IndexPrimitives(class RAS_MeshSlot &ms) = 0; - virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms) = 0; /** * IndexPrimitives_3DText will render text into the polygons. @@ -437,7 +436,7 @@ public: /** * Render Tools */ - virtual void applyTransform(double *oglmatrix, int drawingmode) = 0; + virtual void applyTransform(float *oglmatrix, int drawingmode) = 0; /** * Renders 2D boxes. @@ -461,7 +460,7 @@ public: */ virtual void RenderText3D( int fontid, const char *text, int size, int dpi, - const float color[4], const double mat[16], float aspect) = 0; + const float color[4], const float mat[16], float aspect) = 0; /** * Renders 2D text string. @@ -494,6 +493,11 @@ public: virtual void SetAuxilaryClientInfo(void *inf) = 0; + /** + * Prints information about what the hardware supports. + */ + virtual void PrintHardwareInfo() = 0; + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRasterizer") #endif diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 2078fc99f2e..9cd8f77adfd 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -58,7 +58,7 @@ RAS_MeshSlot::RAS_MeshSlot() : SG_QList() m_bVisible = false; m_bCulled = true; m_bObjectColor = false; - m_RGBAcolor = MT_Vector4(0.0, 0.0, 0.0, 0.0); + m_RGBAcolor = MT_Vector4(0.0f, 0.0f, 0.0f, 0.0f); m_DisplayList = NULL; m_bDisplayList = true; m_joinSlot = NULL; @@ -649,15 +649,13 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa else ms.m_bDisplayList = true; - // for text drawing using faces - if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) + if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) { + // for text drawing using faces rasty->IndexPrimitives_3DText(ms, m_material); - // for multitexturing - else if ((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL))) - rasty->IndexPrimitivesMulti(ms); - // use normal IndexPrimitives - else + } + else { rasty->IndexPrimitives(ms); + } rasty->PopMatrix(); } diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index 1eee99f896b..75cc382c78c 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -128,7 +128,7 @@ public: void* m_clientObj; RAS_Deformer* m_pDeformer; DerivedMesh* m_pDerivedMesh; - double* m_OpenGLMatrix; + float* m_OpenGLMatrix; // visibility bool m_bVisible; bool m_bCulled; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index d2137f2fc79..89e31b62b41 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -49,24 +49,20 @@ set(INC_SYS ) set(SRC - RAS_GLExtensionManager.cpp RAS_ListRasterizer.cpp RAS_OpenGLLight.cpp RAS_OpenGLOffScreen.cpp RAS_OpenGLSync.cpp RAS_OpenGLRasterizer.cpp - RAS_StorageIM.cpp RAS_StorageVA.cpp RAS_StorageVBO.cpp - RAS_GLExtensionManager.h RAS_IStorage.h RAS_ListRasterizer.h RAS_OpenGLLight.h RAS_OpenGLOffScreen.h RAS_OpenGLSync.h RAS_OpenGLRasterizer.h - RAS_StorageIM.h RAS_StorageVA.h RAS_StorageVBO.h ) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp deleted file mode 100644 index bc22d68e218..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 - * of the License, or (at your option) any later version. - * - * 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, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * 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. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp - * \ingroup bgerastogl - */ - - -#include <iostream> - -#include "glew-mx.h" - -#include "RAS_GLExtensionManager.h" - -namespace bgl -{ - void InitExtensions(bool debug) - { - static bool firsttime = true; - - if (firsttime) { - firsttime = false; - - if (debug) { - if (GLEW_ATI_pn_triangles) - std::cout << "Enabled GL_ATI_pn_triangles" << std::endl; - if (GLEW_ARB_texture_env_combine) - std::cout << "Detected GL_ARB_texture_env_combine" << std::endl; - if (GLEW_ARB_texture_cube_map) - std::cout << "Detected GL_ARB_texture_cube_map" << std::endl; - if (GLEW_ARB_multitexture) - std::cout << "Detected GL_ARB_multitexture" << std::endl; - if (GLEW_ARB_shader_objects) - std::cout << "Detected GL_ARB_shader_objects" << std::endl; - if (GLEW_ARB_vertex_shader) - std::cout << "Detected GL_ARB_vertex_shader" << std::endl; - if (GLEW_ARB_fragment_shader) - std::cout << "Detected GL_ARB_fragment_shader" << std::endl; - if (GLEW_ARB_vertex_program) - std::cout << "Detected GL_ARB_vertex_program" << std::endl; - if (GLEW_ARB_depth_texture) - std::cout << "Detected GL_ARB_depth_texture" << std::endl; - if (GLEW_EXT_separate_specular_color) - std::cout << "Detected GL_EXT_separate_specular_color" << std::endl; - } - } - } -} // namespace bgl - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h deleted file mode 100644 index 9f2039b4c6f..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 - * of the License, or (at your option) any later version. - * - * 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, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * 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. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_GLExtensionManager.h - * \ingroup bgerastogl - */ - -#ifndef __RAS_GLEXTENSIONMANAGER_H__ -#define __RAS_GLEXTENSIONMANAGER_H__ - -/** Note: this used to have a lot more code, but now extension handling - * is done by GLEW, so it does mostly debug stuff */ - -namespace bgl -{ - void InitExtensions(bool debug); -} /* namespace bgl */ - -#endif /* __RAS_GLEXTENSIONMANAGER_H__ */ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h index bfa6e1a6cb7..ae0cdcd84af 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h @@ -44,7 +44,6 @@ public: virtual void Exit()=0; virtual void IndexPrimitives(RAS_MeshSlot& ms)=0; - virtual void IndexPrimitivesMulti(RAS_MeshSlot& ms)=0; virtual void SetDrawingMode(int drawingmode)=0; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index 34184f73953..b2d580161ca 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -122,7 +122,7 @@ bool RAS_ListSlot::End() -RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, int storage) +RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, RAS_STORAGE_TYPE storage) : RAS_OpenGLRasterizer(canvas, storage) { } @@ -243,30 +243,6 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms) if (ms.m_bDisplayList) { localSlot = FindOrAdd(ms); localSlot->DrawList(); - if (localSlot->End()) { - // save slot here too, needed for replicas and object using same mesh - // => they have the same vertexarray but different mesh slot - ms.m_DisplayList = localSlot; - return; - } - } - - RAS_OpenGLRasterizer::IndexPrimitives(ms); - - if (ms.m_bDisplayList) { - localSlot->EndList(); - ms.m_DisplayList = localSlot; - } -} - - -void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms) -{ - RAS_ListSlot* localSlot =0; - - if (ms.m_bDisplayList) { - localSlot = FindOrAdd(ms); - localSlot->DrawList(); if (localSlot->End()) { // save slot here too, needed for replicas and object using same mesh @@ -276,7 +252,7 @@ void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms) } } - RAS_OpenGLRasterizer::IndexPrimitivesMulti(ms); + RAS_OpenGLRasterizer::IndexPrimitives(ms); if (ms.m_bDisplayList) { localSlot->EndList(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h index 5e1c662bc17..e3e6931311b 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h @@ -56,11 +56,10 @@ class RAS_ListRasterizer : public RAS_OpenGLRasterizer public: void RemoveListSlot(RAS_ListSlot* list); - RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock=false, int storage=RAS_AUTO_STORAGE); + RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, RAS_STORAGE_TYPE storage); virtual ~RAS_ListRasterizer(); virtual void IndexPrimitives(class RAS_MeshSlot& ms); - virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms); virtual bool Init(); virtual void Exit(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp index 6199b0042ac..e4992f9847a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp @@ -100,13 +100,13 @@ bool RAS_OpenGLLight::ApplyFixedFunctionLighting(KX_Scene *kxscene, int oblayer, //vec[0] = base->object->obmat[2][0]; //vec[1] = base->object->obmat[2][1]; //vec[2] = base->object->obmat[2][2]; - vec[3] = 0.0; + vec[3] = 0.0f; glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec); } else { - //vec[3] = 1.0; + //vec[3] = 1.0f; glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec); - glLightf((GLenum)(GL_LIGHT0+slot), GL_CONSTANT_ATTENUATION, 1.0); + glLightf((GLenum)(GL_LIGHT0+slot), GL_CONSTANT_ATTENUATION, 1.0f); glLightf((GLenum)(GL_LIGHT0+slot), GL_LINEAR_ATTENUATION, m_att1/m_distance); // without this next line it looks backward compatible. //attennuation still is acceptable @@ -124,30 +124,30 @@ bool RAS_OpenGLLight::ApplyFixedFunctionLighting(KX_Scene *kxscene, int oblayer, glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_EXPONENT, 128.0f * m_spotblend); } else { - glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, 180.0); + glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, 180.0f); } } if (m_nodiffuse) { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + vec[0] = vec[1] = vec[2] = vec[3] = 0.0f; } else { vec[0] = m_energy*m_color[0]; vec[1] = m_energy*m_color[1]; vec[2] = m_energy*m_color[2]; - vec[3] = 1.0; + vec[3] = 1.0f; } glLightfv((GLenum)(GL_LIGHT0+slot), GL_DIFFUSE, vec); if (m_nospecular) { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + vec[0] = vec[1] = vec[2] = vec[3] = 0.0f; } else if (m_nodiffuse) { vec[0] = m_energy*m_color[0]; vec[1] = m_energy*m_color[1]; vec[2] = m_energy*m_color[2]; - vec[3] = 1.0; + vec[3] = 1.0f; } glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPECULAR, vec); @@ -262,7 +262,7 @@ void RAS_OpenGLLight::Update() // lights don't get their openGL matrix updated, do it now if (kxlight->GetSGNode()->IsDirty()) kxlight->GetOpenGLMatrix(); - double *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer(); + float *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer(); for (int i=0; i<4; i++) for (int j=0; j<4; j++, dobmat++) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 77141140b7e..d85bda0389e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -49,15 +49,17 @@ #include "RAS_OpenGLOffScreen.h" #include "RAS_OpenGLSync.h" -#include "RAS_StorageIM.h" #include "RAS_StorageVA.h" #include "RAS_StorageVBO.h" #include "GPU_draw.h" +#include "GPU_extensions.h" #include "GPU_material.h" +#include "GPU_shader.h" extern "C"{ #include "BLF_api.h" + #include "BKE_DerivedMesh.h" } @@ -85,22 +87,22 @@ static GLuint right_eye_vinterlace_mask[32]; */ static GLuint hinterlace_mask[33]; -RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage) +RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, RAS_STORAGE_TYPE storage) :RAS_IRasterizer(canvas), m_2DCanvas(canvas), m_fogenabled(false), - m_time(0.0), + m_time(0.0f), m_campos(0.0f, 0.0f, 0.0f), m_camortho(false), m_camnegscale(false), m_stereomode(RAS_STEREO_NOSTEREO), m_curreye(RAS_STEREO_LEFTEYE), - m_eyeseparation(0.0), - m_focallength(0.0), + m_eyeseparation(0.0f), + m_focallength(0.0f), m_setfocallength(false), m_noOfScanlines(32), m_motionblur(0), - m_motionblurvalue(-1.0), + m_motionblurvalue(-1.0f), m_usingoverrideshader(false), m_clientobject(NULL), m_auxilaryClientInfo(NULL), @@ -125,27 +127,22 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage) m_prevafvalue = GPU_get_anisotropic(); - if (m_storage_type == RAS_VBO /*|| m_storage_type == RAS_AUTO_STORAGE && GLEW_ARB_vertex_buffer_object*/) - { + if (m_storage_type == RAS_VBO /*|| m_storage_type == RAS_AUTO_STORAGE && GLEW_ARB_vertex_buffer_object*/) { m_storage = new RAS_StorageVBO(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_storage_type = RAS_VBO; } - else if ((m_storage_type == RAS_VA) || (m_storage_type == RAS_AUTO_STORAGE && GLEW_VERSION_1_1)) - { + else if ((m_storage_type == RAS_VA) || (m_storage_type == RAS_AUTO_STORAGE)) { m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_storage_type = RAS_VA; } - else - { - m_storage = m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_storage_type = RAS_IMMEDIATE; + else { + printf("Unknown rasterizer storage type, falling back to vertex arrays\n"); + m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); } glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights); if (m_numgllights < 8) m_numgllights = 8; + + PrintHardwareInfo(); } @@ -154,8 +151,6 @@ RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer() { // Restore the previous AF value GPU_set_anisotropic(m_prevafvalue); - if (m_failsafe_storage && m_failsafe_storage != m_storage) - delete m_failsafe_storage; if (m_storage) delete m_storage; @@ -179,10 +174,10 @@ bool RAS_OpenGLRasterizer::Init() glFrontFace(GL_CCW); m_last_frontface = true; - m_redback = 0.4375; - m_greenback = 0.4375; - m_blueback = 0.4375; - m_alphaback = 0.0; + m_redback = 0.4375f; + m_greenback = 0.4375f; + m_blueback = 0.4375f; + m_alphaback = 0.0f; glClearColor(m_redback,m_greenback,m_blueback,m_alphaback); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); @@ -257,7 +252,7 @@ void RAS_OpenGLRasterizer::Exit() glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); - glClearDepth(1.0); + glClearDepth(1.0f); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glClearColor(m_redback, m_greenback, m_blueback, m_alphaback); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -324,9 +319,6 @@ void RAS_OpenGLRasterizer::SetDrawingMode(int drawingmode) glDisable(GL_CULL_FACE); m_storage->SetDrawingMode(drawingmode); - if (m_failsafe_storage && m_failsafe_storage != m_storage) { - m_failsafe_storage->SetDrawingMode(drawingmode); - } } int RAS_OpenGLRasterizer::GetDrawingMode() @@ -382,8 +374,8 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene) glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f); const MT_Scalar *fromPtr = &debugShapes[i].m_pos.x(); const MT_Scalar *toPtr= &debugShapes[i].m_param.x(); - glVertex3dv(fromPtr); - glVertex3dv(toPtr); + glVertex3fv(fromPtr); + glVertex3fv(toPtr); } glEnd(); @@ -394,7 +386,7 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene) glBegin(GL_LINE_LOOP); glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f); - static const MT_Vector3 worldUp(0.0, 0.0, 1.0); + static const MT_Vector3 worldUp(0.0f, 0.0f, 1.0f); MT_Vector3 norm = debugShapes[i].m_param; MT_Matrix3x3 tr; if (norm.fuzzyZero() || norm == worldUp) @@ -414,12 +406,12 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene) int n = (int)debugShapes[i].m_param2.y(); for (int j = 0; j<n; j++) { - MT_Scalar theta = j*M_PI*2/n; - MT_Vector3 pos(cos(theta) * rad, sin(theta) * rad, 0.0); + MT_Scalar theta = j*(float)M_PI*2/n; + MT_Vector3 pos(cosf(theta) * rad, sinf(theta) * rad, 0.0f); pos = pos*tr; pos += debugShapes[i].m_pos; const MT_Scalar* posPtr = &pos.x(); - glVertex3dv(posPtr); + glVertex3fv(posPtr); } glEnd(); } @@ -557,13 +549,15 @@ void RAS_OpenGLRasterizer::SetEye(const StereoEye eye) glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); } else { - //glAccum(GL_LOAD, 1.0); + //glAccum(GL_LOAD, 1.0f); glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE); ClearDepthBuffer(); } break; case RAS_STEREO_VINTERLACE: { + // OpenGL stippling is deprecated, it is no longer possible to affect all shaders + // this way, offscreen rendering and then compositing may be the better solution glEnable(GL_POLYGON_STIPPLE); glPolygonStipple((const GLubyte*) ((m_curreye == RAS_STEREO_LEFTEYE) ? left_eye_vinterlace_mask : right_eye_vinterlace_mask)); if (m_curreye == RAS_STEREO_RIGHTEYE) @@ -765,38 +759,118 @@ void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit, int layer) void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms) { if (ms.m_pDerivedMesh) - m_failsafe_storage->IndexPrimitives(ms); + DrawDerivedMesh(ms); else m_storage->IndexPrimitives(ms); } -void RAS_OpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms) +// Code for hooking into Blender's mesh drawing for derived meshes. +// If/when we use more of Blender's drawing code, we may be able to +// clean this up +static bool current_wireframe; +static RAS_MaterialBucket *current_bucket; +static RAS_IPolyMaterial *current_polymat; +static RAS_MeshSlot *current_ms; +static RAS_MeshObject *current_mesh; +static int current_blmat_nr; +static GPUVertexAttribs current_gpu_attribs; +static Image *current_image; +static int CheckMaterialDM(int matnr, void *attribs) +{ + // only draw the current material + if (matnr != current_blmat_nr) + return 0; + GPUVertexAttribs *gattribs = (GPUVertexAttribs *)attribs; + if (gattribs) + memcpy(gattribs, ¤t_gpu_attribs, sizeof(GPUVertexAttribs)); + return 1; +} + +static DMDrawOption CheckTexDM(MTexPoly *mtexpoly, const bool has_mcol, int matnr) +{ + + // index is the original face index, retrieve the polygon + if (matnr == current_blmat_nr && + (mtexpoly == NULL || mtexpoly->tpage == current_image)) { + // must handle color. + if (current_wireframe) + return DM_DRAW_OPTION_NO_MCOL; + if (current_ms->m_bObjectColor) { + MT_Vector4& rgba = current_ms->m_RGBAcolor; + glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); + // don't use mcol + return DM_DRAW_OPTION_NO_MCOL; + } + if (!has_mcol) { + // we have to set the color from the material + unsigned char rgba[4]; + current_polymat->GetMaterialRGBAColor(rgba); + glColor4ubv((const GLubyte *)rgba); + return DM_DRAW_OPTION_NORMAL; + } + return DM_DRAW_OPTION_NORMAL; + } + return DM_DRAW_OPTION_SKIP; +} + +void RAS_OpenGLRasterizer::DrawDerivedMesh(class RAS_MeshSlot &ms) { - if (ms.m_pDerivedMesh) - m_failsafe_storage->IndexPrimitivesMulti(ms); + // mesh data is in derived mesh, + current_bucket = ms.m_bucket; + current_polymat = current_bucket->GetPolyMaterial(); + current_ms = &ms; + current_mesh = ms.m_mesh; + current_wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME; + // MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); /* UNUSED */ + + // handle two-side + if (current_polymat->GetDrawingMode() & RAS_IRasterizer::KX_BACKCULL) + this->SetCullFace(true); else - m_storage->IndexPrimitivesMulti(ms); + this->SetCullFace(false); + + if (current_polymat->GetFlag() & RAS_BLENDERGLSL) { + // GetMaterialIndex return the original mface material index, + // increment by 1 to match what derived mesh is doing + current_blmat_nr = current_polymat->GetMaterialIndex()+1; + // For GLSL we need to retrieve the GPU material attribute + Material* blmat = current_polymat->GetBlenderMaterial(); + Scene* blscene = current_polymat->GetBlenderScene(); + if (!current_wireframe && blscene && blmat) + GPU_material_vertex_attributes(GPU_material_from_blender(blscene, blmat, false), ¤t_gpu_attribs); + else + memset(¤t_gpu_attribs, 0, sizeof(current_gpu_attribs)); + // DM draw can mess up blending mode, restore at the end + int current_blend_mode = GPU_get_material_alpha_blend(); + ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM); + GPU_set_material_alpha_blend(current_blend_mode); + } else { + //ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol); + current_blmat_nr = current_polymat->GetMaterialIndex(); + current_image = current_polymat->GetBlenderImage(); + ms.m_pDerivedMesh->drawFacesTex(ms.m_pDerivedMesh, CheckTexDM, NULL, NULL, DM_DRAW_USE_ACTIVE_UV); + } } void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat) { glMatrixMode(GL_PROJECTION); - double* matrix = &mat(0, 0); - glLoadMatrixd(matrix); + float* matrix = &mat(0, 0); + glLoadMatrixf(matrix); - m_camortho = (mat(3, 3) != 0.0); + m_camortho = (mat(3, 3) != 0.0f); } void RAS_OpenGLRasterizer::SetProjectionMatrix(const MT_Matrix4x4 & mat) { glMatrixMode(GL_PROJECTION); - double matrix[16]; + float matrix[16]; /* Get into argument. Looks a bit dodgy, but it's ok. */ mat.getValue(matrix); /* Internally, MT_Matrix4x4 uses doubles (MT_Scalar). */ - glLoadMatrixd(matrix); + glLoadMatrixf(matrix); - m_camortho= (mat[3][3] != 0.0); + m_camortho= (mat[3][3] != 0.0f); } MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( @@ -810,7 +884,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( bool ) { MT_Matrix4x4 result; - double mat[16]; + float mat[16]; // correction for stereo if (Stereo()) @@ -849,7 +923,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( glLoadIdentity(); glFrustum(left, right, bottom, top, frustnear, frustfar); - glGetDoublev(GL_PROJECTION_MATRIX, mat); + glGetFloatv(GL_PROJECTION_MATRIX, mat); result.setValue(mat); return result; @@ -864,14 +938,14 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix( float frustfar ) { MT_Matrix4x4 result; - double mat[16]; + float mat[16]; // stereo is meaning less for orthographic, disable it glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(left, right, bottom, top, frustnear, frustfar); - glGetDoublev(GL_PROJECTION_MATRIX, mat); + glGetFloatv(GL_PROJECTION_MATRIX, mat); result.setValue(mat); return result; @@ -890,8 +964,8 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, // correction for stereo if (Stereo() && perspective) { - MT_Vector3 unitViewDir(0.0, -1.0, 0.0); // minus y direction, Blender convention - MT_Vector3 unitViewupVec(0.0, 0.0, 1.0); + MT_Vector3 unitViewDir(0.0f, -1.0f, 0.0f); // minus y direction, Blender convention + MT_Vector3 unitViewupVec(0.0f, 0.0f, 1.0f); MT_Vector3 viewDir, viewupVec; MT_Vector3 eyeline; @@ -909,7 +983,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, // translate to left by half the eye distance MT_Transform transform; transform.setIdentity(); - transform.translate(-(eyeline * m_eyeseparation / 2.0)); + transform.translate(-(eyeline * m_eyeseparation / 2.0f)); m_viewmatrix *= transform; } break; @@ -918,7 +992,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, // translate to right by half the eye distance MT_Transform transform; transform.setIdentity(); - transform.translate(eyeline * m_eyeseparation / 2.0); + transform.translate(eyeline * m_eyeseparation / 2.0f); m_viewmatrix *= transform; } break; @@ -934,7 +1008,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, m_viewmatrix.getValue(glviewmat); glMatrixMode(GL_MODELVIEW); - glLoadMatrixd(glviewmat); + glLoadMatrixf(glviewmat); m_campos = pos; m_camnegscale = ((scale[0] < 0.0) ^ (scale[1] < 0.0) ^ (scale[2] < 0.0)) ? true : false; } @@ -1027,7 +1101,7 @@ void RAS_OpenGLRasterizer::EnableMotionBlur(float motionblurvalue) void RAS_OpenGLRasterizer::DisableMotionBlur() { m_motionblur = 0; - m_motionblurvalue = -1.0; + m_motionblurvalue = -1.0f; } void RAS_OpenGLRasterizer::SetAlphaBlend(int alphablend) @@ -1251,7 +1325,7 @@ void RAS_OpenGLRasterizer::RemoveLight(RAS_ILightObject* lightobject) m_lights.erase(lit); } -bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, double *oglmatrix) +bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, float *oglmatrix) { if (result->m_hitMesh) { @@ -1265,14 +1339,14 @@ bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast left = (dir.cross(resultnormal)).safe_normalized(); // for the up vector, we take the 'resultnormal' returned by the physics - double maat[16] = {left[0], left[1], left[2], 0, + float maat[16] = {left[0], left[1], left[2], 0, dir[0], dir[1], dir[2], 0, resultnormal[0], resultnormal[1], resultnormal[2], 0, 0, 0, 0, 1}; - glTranslated(oglmatrix[12],oglmatrix[13],oglmatrix[14]); + glTranslatef(oglmatrix[12],oglmatrix[13],oglmatrix[14]); //glMultMatrixd(oglmatrix); - glMultMatrixd(maat); + glMultMatrixf(maat); return true; } else { @@ -1280,7 +1354,7 @@ bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast } } -void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode ) +void RAS_OpenGLRasterizer::applyTransform(float* oglmatrix,int objectdrawmode ) { /* FIXME: blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const @@ -1301,14 +1375,14 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode ) //page 360/361 3D Game Engine Design, David Eberly for a discussion // on screen aligned and axis aligned billboards // assumed is that the preprocessor transformed all billboard polygons - // so that their normal points into the positive x direction (1.0, 0.0, 0.0) + // so that their normal points into the positive x direction (1.0f, 0.0f, 0.0f) // when new parenting for objects is done, this rotation // will be moved into the object MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]); MT_Point3 campos = GetCameraPosition(); MT_Vector3 dir = (campos - objpos).safe_normalized(); - MT_Vector3 up(0,0,1.0); + MT_Vector3 up(0,0,1.0f); KX_GameObject* gameobj = (KX_GameObject*)m_clientobject; // get scaling of halo object @@ -1333,13 +1407,13 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode ) dir *= size[1]; up *= size[2]; - double maat[16] = {left[0], left[1], left[2], 0, + float maat[16] = {left[0], left[1], left[2], 0, dir[0], dir[1], dir[2], 0, up[0], up[1], up[2], 0, 0, 0, 0, 1}; glTranslatef(objpos[0],objpos[1],objpos[2]); - glMultMatrixd(maat); + glMultMatrixf(maat); } else { @@ -1363,11 +1437,11 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode ) if (!physics_controller && parent) physics_controller = parent->GetPhysicsController(); - KX_RayCast::Callback<RAS_OpenGLRasterizer, double> callback(this, physics_controller, oglmatrix); + KX_RayCast::Callback<RAS_OpenGLRasterizer, float> callback(this, physics_controller, oglmatrix); if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback)) { // couldn't find something to cast the shadow on... - glMultMatrixd(oglmatrix); + glMultMatrixf(oglmatrix); } else { // we found the "ground", but the cast matrix doesn't take @@ -1379,7 +1453,7 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode ) { // 'normal' object - glMultMatrixd(oglmatrix); + glMultMatrixf(oglmatrix); } } } @@ -1468,7 +1542,7 @@ void RAS_OpenGLRasterizer::RenderBox2D(int xco, void RAS_OpenGLRasterizer::RenderText3D( int fontid, const char *text, int size, int dpi, - const float color[4], const double mat[16], float aspect) + const float color[4], const float mat[16], float aspect) { /* gl prepping */ DisableForText(); @@ -1555,13 +1629,13 @@ void RAS_OpenGLRasterizer::MotionBlur() if (state==1) { //bugfix:load color buffer into accum buffer for the first time(state=1) - glAccum(GL_LOAD, 1.0); + glAccum(GL_LOAD, 1.0f); SetMotionBlurState(2); } else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) { glAccum(GL_MULT, motionblurvalue); glAccum(GL_ACCUM, 1-motionblurvalue); - glAccum(GL_RETURN, 1.0); + glAccum(GL_RETURN, 1.0f); glFlush(); } } @@ -1583,3 +1657,68 @@ void RAS_OpenGLRasterizer::SetAuxilaryClientInfo(void* inf) m_auxilaryClientInfo = inf; } +void RAS_OpenGLRasterizer::PrintHardwareInfo() +{ + #define pprint(x) std::cout << x << std::endl; + + pprint("GL_VENDOR: " << glGetString(GL_VENDOR)); + pprint("GL_RENDERER: " << glGetString(GL_RENDERER)); + pprint("GL_VERSION: " << glGetString(GL_VERSION)); + bool support=0; + pprint("Supported Extensions..."); + pprint(" GL_ARB_shader_objects supported? "<< (GLEW_ARB_shader_objects?"yes.":"no.")); + + support= GLEW_ARB_vertex_shader; + pprint(" GL_ARB_vertex_shader supported? "<< (support?"yes.":"no.")); + if (support) { + pprint(" ----------Details----------"); + int max=0; + glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, (GLint*)&max); + pprint(" Max uniform components." << max); + + glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, (GLint*)&max); + pprint(" Max varying floats." << max); + + glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max); + pprint(" Max vertex texture units." << max); + + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max); + pprint(" Max combined texture units." << max); + pprint(""); + } + + support=GLEW_ARB_fragment_shader; + pprint(" GL_ARB_fragment_shader supported? "<< (support?"yes.":"no.")); + if (support) { + pprint(" ----------Details----------"); + int max=0; + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, (GLint*)&max); + pprint(" Max uniform components." << max); + pprint(""); + } + + support = GLEW_ARB_texture_cube_map; + pprint(" GL_ARB_texture_cube_map supported? "<< (support?"yes.":"no.")); + if (support) { + pprint(" ----------Details----------"); + int size=0; + glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, (GLint*)&size); + pprint(" Max cubemap size." << size); + pprint(""); + } + + support = GLEW_ARB_multitexture; + pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no.")); + if (support) { + pprint(" ----------Details----------"); + int units=0; + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units); + pprint(" Max texture units available. " << units); + pprint(""); + } + + pprint(" GL_ARB_texture_env_combine supported? "<< (GLEW_ARB_texture_env_combine?"yes.":"no.")); + + pprint(" GL_ARB_texture_non_power_of_two supported " << (GPU_full_non_power_of_two_support()?"yes.":"no.")); +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 0c9904d1776..5554ebbe49c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -56,7 +56,6 @@ class RAS_OpenGLLight; enum RAS_STORAGE_TYPE { RAS_AUTO_STORAGE, - RAS_IMMEDIATE, RAS_VA, RAS_VBO, }; @@ -140,11 +139,10 @@ protected: * Examples of concrete strategies: Vertex Arrays, VBOs, Immediate Mode*/ int m_storage_type; RAS_IStorage *m_storage; - RAS_IStorage *m_failsafe_storage; /* So derived mesh can use immediate mode */ public: double GetTime(); - RAS_OpenGLRasterizer(RAS_ICanvas *canv, int storage=RAS_AUTO_STORAGE); + RAS_OpenGLRasterizer(RAS_ICanvas *canv, RAS_STORAGE_TYPE storage); virtual ~RAS_OpenGLRasterizer(); /*enum DrawType @@ -188,8 +186,8 @@ public: virtual void SwapBuffers(); virtual void IndexPrimitives(class RAS_MeshSlot &ms); - virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms); virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat); + virtual void DrawDerivedMesh(class RAS_MeshSlot &ms); virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat); virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat); @@ -301,17 +299,17 @@ public: void RenderBox2D(int xco, int yco, int width, int height, float percentage); void RenderText3D(int fontid, const char *text, int size, int dpi, - const float color[4], const double mat[16], float aspect); + const float color[4], const float mat[16], float aspect); void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char *text, int xco, int yco, int width, int height); - void applyTransform(double *oglmatrix, int objectdrawmode); + void applyTransform(float *oglmatrix, int objectdrawmode); void PushMatrix(); void PopMatrix(); /// \see KX_RayCast - bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, double *oglmatrix); + bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, float *oglmatrix); /// \see KX_RayCast bool NeedRayCast(struct KX_ClientObjectInfo *, void *UNUSED(data)) { return true; } @@ -327,6 +325,10 @@ public: void SetAuxilaryClientInfo(void *inf); + /** + * Prints information about what the hardware supports. + */ + virtual void PrintHardwareInfo(); #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_OpenGLRasterizer") diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp deleted file mode 100644 index 2cf6088629a..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 - * of the License, or (at your option) any later version. - * - * 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, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * 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. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "RAS_StorageIM.h" -#include "RAS_MaterialBucket.h" -#include "RAS_IPolygonMaterial.h" - -#include "glew-mx.h" -#include "GPU_draw.h" -#include "GPU_extensions.h" -#include "GPU_material.h" - -extern "C"{ - #include "BKE_DerivedMesh.h" -} - -RAS_StorageIM::RAS_StorageIM(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer) : - m_drawingmode(RAS_IRasterizer::KX_TEXTURED), - m_texco_num(texco_num), - m_attrib_num(attrib_num), - m_texco(texco), - m_attrib(attrib), - m_attrib_layer(attrib_layer) -{ -} -RAS_StorageIM::~RAS_StorageIM() -{ -} - -bool RAS_StorageIM::Init() -{ - return true; -} -void RAS_StorageIM::Exit() -{ -} - -void RAS_StorageIM::IndexPrimitives(RAS_MeshSlot& ms) -{ - IndexPrimitivesInternal(ms, false); -} - -void RAS_StorageIM::IndexPrimitivesMulti(class RAS_MeshSlot& ms) -{ - IndexPrimitivesInternal(ms, true); -} - -void RAS_StorageIM::TexCoord(const RAS_TexVert &tv) -{ - int unit; - - if (GLEW_ARB_multitexture) { - for (unit = 0; unit < *m_texco_num; unit++) { - switch (m_texco[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - glMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, tv.getXYZ()); - break; - case RAS_IRasterizer::RAS_TEXCO_UV: - glMultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, tv.getUV(unit)); - break; - case RAS_IRasterizer::RAS_TEXCO_NORM: - glMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, tv.getNormal()); - break; - case RAS_IRasterizer::RAS_TEXTANGENT: - glMultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, tv.getTangent()); - break; - default: - break; - } - } - } - - if (GLEW_ARB_vertex_program) { - for (unit = 0; unit < *m_attrib_num; unit++) { - switch (m_attrib[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - glVertexAttrib3fvARB(unit, tv.getXYZ()); - break; - case RAS_IRasterizer::RAS_TEXCO_UV: - glVertexAttrib2fvARB(unit, tv.getUV(m_attrib_layer[unit])); - break; - case RAS_IRasterizer::RAS_TEXCO_NORM: - glVertexAttrib3fvARB(unit, tv.getNormal()); - break; - case RAS_IRasterizer::RAS_TEXTANGENT: - glVertexAttrib4fvARB(unit, tv.getTangent()); - break; - case RAS_IRasterizer::RAS_TEXCO_VCOL: - glVertexAttrib4ubvARB(unit, tv.getRGBA()); - break; - default: - break; - } - } - } - -} - -void RAS_StorageIM::SetCullFace(bool enable) -{ - if (enable) - glEnable(GL_CULL_FACE); - else - glDisable(GL_CULL_FACE); -} - -static bool current_wireframe; -static RAS_MaterialBucket *current_bucket; -static RAS_IPolyMaterial *current_polymat; -static RAS_MeshSlot *current_ms; -static RAS_MeshObject *current_mesh; -static int current_blmat_nr; -static GPUVertexAttribs current_gpu_attribs; -static Image *current_image; -static int CheckMaterialDM(int matnr, void *attribs) -{ - // only draw the current material - if (matnr != current_blmat_nr) - return 0; - GPUVertexAttribs *gattribs = (GPUVertexAttribs *)attribs; - if (gattribs) - memcpy(gattribs, ¤t_gpu_attribs, sizeof(GPUVertexAttribs)); - return 1; -} - -/* -static int CheckTexfaceDM(void *mcol, int index) -{ - - // index is the original face index, retrieve the polygon - RAS_Polygon* polygon = (index >= 0 && index < current_mesh->NumPolygons()) ? - current_mesh->GetPolygon(index) : NULL; - if (polygon && polygon->GetMaterial() == current_bucket) { - // must handle color. - if (current_wireframe) - return 2; - if (current_ms->m_bObjectColor) { - MT_Vector4& rgba = current_ms->m_RGBAcolor; - glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); - // don't use mcol - return 2; - } - if (!mcol) { - // we have to set the color from the material - unsigned char rgba[4]; - current_polymat->GetMaterialRGBAColor(rgba); - glColor4ubv((const GLubyte *)rgba); - return 2; - } - return 1; - } - return 0; -} -*/ - -static DMDrawOption CheckTexDM(MTexPoly *mtexpoly, const bool has_mcol, int matnr) -{ - - // index is the original face index, retrieve the polygon - if (matnr == current_blmat_nr && - (mtexpoly == NULL || mtexpoly->tpage == current_image)) { - // must handle color. - if (current_wireframe) - return DM_DRAW_OPTION_NO_MCOL; - if (current_ms->m_bObjectColor) { - MT_Vector4& rgba = current_ms->m_RGBAcolor; - glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); - // don't use mcol - return DM_DRAW_OPTION_NO_MCOL; - } - if (!has_mcol) { - // we have to set the color from the material - unsigned char rgba[4]; - current_polymat->GetMaterialRGBAColor(rgba); - glColor4ubv((const GLubyte *)rgba); - return DM_DRAW_OPTION_NO_MCOL; - } - return DM_DRAW_OPTION_NORMAL; - } - return DM_DRAW_OPTION_SKIP; -} - -void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi) -{ - bool obcolor = ms.m_bObjectColor; - bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME; - MT_Vector4& rgba = ms.m_RGBAcolor; - RAS_MeshSlot::iterator it; - - if (ms.m_pDerivedMesh) { - // mesh data is in derived mesh, - current_bucket = ms.m_bucket; - current_polymat = current_bucket->GetPolyMaterial(); - current_ms = &ms; - current_mesh = ms.m_mesh; - current_wireframe = wireframe; - // MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); /* UNUSED */ - - // handle two-side - if (current_polymat->GetDrawingMode() & RAS_IRasterizer::KX_BACKCULL) - this->SetCullFace(true); - else - this->SetCullFace(false); - - if (current_polymat->GetFlag() & RAS_BLENDERGLSL) { - // GetMaterialIndex return the original mface material index, - // increment by 1 to match what derived mesh is doing - current_blmat_nr = current_polymat->GetMaterialIndex()+1; - // For GLSL we need to retrieve the GPU material attribute - Material* blmat = current_polymat->GetBlenderMaterial(); - Scene* blscene = current_polymat->GetBlenderScene(); - if (!wireframe && blscene && blmat) - GPU_material_vertex_attributes(GPU_material_from_blender(blscene, blmat, false), ¤t_gpu_attribs); - else - memset(¤t_gpu_attribs, 0, sizeof(current_gpu_attribs)); - // DM draw can mess up blending mode, restore at the end - int current_blend_mode = GPU_get_material_alpha_blend(); - ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM); - GPU_set_material_alpha_blend(current_blend_mode); - } else { - //ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol); - current_blmat_nr = current_polymat->GetMaterialIndex(); - current_image = current_polymat->GetBlenderImage(); - ms.m_pDerivedMesh->drawFacesTex(ms.m_pDerivedMesh, CheckTexDM, NULL, NULL, DM_DRAW_USE_ACTIVE_UV); - } - return; - } - // iterate over display arrays, each containing an index + vertex array - for (ms.begin(it); !ms.end(it); ms.next(it)) { - RAS_TexVert *vertex; - size_t i, j, numvert; - - numvert = it.array->m_type; - - if (it.array->m_type == RAS_DisplayArray::LINE) { - // line drawing - glBegin(GL_LINES); - - for (i = 0; i < it.totindex; i += 2) - { - vertex = &it.vertex[it.index[i]]; - glVertex3fv(vertex->getXYZ()); - - vertex = &it.vertex[it.index[i+1]]; - glVertex3fv(vertex->getXYZ()); - } - - glEnd(); - } - else { - // triangle and quad drawing - if (it.array->m_type == RAS_DisplayArray::TRIANGLE) - glBegin(GL_TRIANGLES); - else - glBegin(GL_QUADS); - - for (i = 0; i < it.totindex; i += numvert) - { - if (obcolor) - glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); - - for (j = 0; j < numvert; j++) { - vertex = &it.vertex[it.index[i+j]]; - - if (!wireframe) { - if (!obcolor) - glColor4ubv((const GLubyte *)(vertex->getRGBA())); - - glNormal3fv(vertex->getNormal()); - - if (multi) - TexCoord(*vertex); - else - glTexCoord2fv(vertex->getUV(0)); - } - - glVertex3fv(vertex->getXYZ()); - } - } - - glEnd(); - } - } -} diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h deleted file mode 100644 index 54ba2a57b61..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 - * of the License, or (at your option) any later version. - * - * 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, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * 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. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __KX_IMMEDIATEMODESTORAGE -#define __KX_IMMEDIATEMODESTORAGE - -#include "RAS_IStorage.h" -#include "RAS_IRasterizer.h" - -class RAS_StorageIM : public RAS_IStorage -{ -public: - RAS_StorageIM(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer); - virtual ~RAS_StorageIM(); - - virtual bool Init(); - virtual void Exit(); - - virtual void IndexPrimitives(RAS_MeshSlot& ms); - virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms); - - virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;}; - -protected: - int m_drawingmode; - int* m_texco_num; - int* m_attrib_num; - RAS_IRasterizer::TexCoGen* m_texco; - RAS_IRasterizer::TexCoGen* m_attrib; - int* m_attrib_layer; - - void TexCoord(const RAS_TexVert &tv); - void SetCullFace(bool enable); - - void IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi); - - -#ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageIM"); } - void operator delete( void *mem ) { MEM_freeN(mem); } -#endif -}; - -#endif //__KX_IMMEDIATEMODESTORAGE diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp index c2980a6c15f..cf77ebfbeb9 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp @@ -56,68 +56,7 @@ void RAS_StorageVA::Exit() { } -void RAS_StorageVA::IndexPrimitives(RAS_MeshSlot& ms) -{ - static const GLsizei stride = sizeof(RAS_TexVert); - bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME; - RAS_MeshSlot::iterator it; - GLenum drawmode; - - if (!wireframe) - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - - // use glDrawElements to draw each vertexarray - for (ms.begin(it); !ms.end(it); ms.next(it)) { - if (it.totindex == 0) - continue; - - // drawing mode - if (it.array->m_type == RAS_DisplayArray::TRIANGLE) - drawmode = GL_TRIANGLES; - else if (it.array->m_type == RAS_DisplayArray::QUAD) - drawmode = GL_QUADS; - else - drawmode = GL_LINES; - - // colors - if (drawmode != GL_LINES && !wireframe) { - if (ms.m_bObjectColor) { - const MT_Vector4& rgba = ms.m_RGBAcolor; - - glDisableClientState(GL_COLOR_ARRAY); - glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); - } - else { - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - glEnableClientState(GL_COLOR_ARRAY); - } - } - else - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - - glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ()); - glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal()); - if (!wireframe) { - glTexCoordPointer(2, GL_FLOAT, stride, it.vertex->getUV(0)); - if (glIsEnabled(GL_COLOR_ARRAY)) - glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA()); - } - - // here the actual drawing takes places - glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index); - } - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - if (!wireframe) { - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - } -} - -void RAS_StorageVA::IndexPrimitivesMulti(class RAS_MeshSlot& ms) +void RAS_StorageVA::IndexPrimitives(class RAS_MeshSlot& ms) { static const GLsizei stride = sizeof(RAS_TexVert); bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_color_array = true; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h index e4d00310a11..34fdca23ee6 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h @@ -44,7 +44,6 @@ public: virtual void Exit(); virtual void IndexPrimitives(RAS_MeshSlot& ms); - virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms); virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;}; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp index 58f3d4c05da..08d27cbc3fc 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp @@ -80,7 +80,7 @@ void VBO::UpdateIndices() &data->m_index[0], GL_STATIC_DRAW); } -void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi) +void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer) { int unit; @@ -100,41 +100,32 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, glEnableClientState(GL_COLOR_ARRAY); glColorPointer(4, GL_UNSIGNED_BYTE, this->stride, this->color_offset); - if (multi) + for (unit = 0; unit < texco_num; ++unit) { - for (unit = 0; unit < texco_num; ++unit) - { - glClientActiveTexture(GL_TEXTURE0_ARB + unit); - switch (texco[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(3, GL_FLOAT, this->stride, this->vertex_offset); - break; - case RAS_IRasterizer::RAS_TEXCO_UV: - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2, GL_FLOAT, this->stride, (void*)((intptr_t)this->uv_offset+(sizeof(GLfloat)*2*unit))); - break; - case RAS_IRasterizer::RAS_TEXCO_NORM: - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(3, GL_FLOAT, this->stride, this->normal_offset); - break; - case RAS_IRasterizer::RAS_TEXTANGENT: - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(4, GL_FLOAT, this->stride, this->tangent_offset); - break; - default: - break; - } + glClientActiveTexture(GL_TEXTURE0_ARB + unit); + switch (texco[unit]) { + case RAS_IRasterizer::RAS_TEXCO_ORCO: + case RAS_IRasterizer::RAS_TEXCO_GLOB: + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(3, GL_FLOAT, this->stride, this->vertex_offset); + break; + case RAS_IRasterizer::RAS_TEXCO_UV: + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2, GL_FLOAT, this->stride, (void*)((intptr_t)this->uv_offset+(sizeof(GLfloat)*2*unit))); + break; + case RAS_IRasterizer::RAS_TEXCO_NORM: + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(3, GL_FLOAT, this->stride, this->normal_offset); + break; + case RAS_IRasterizer::RAS_TEXTANGENT: + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(4, GL_FLOAT, this->stride, this->tangent_offset); + break; + default: + break; } - glClientActiveTextureARB(GL_TEXTURE0_ARB); - } - else //TexFace - { - glClientActiveTextureARB(GL_TEXTURE0_ARB); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2, GL_FLOAT, this->stride, this->uv_offset); } + glClientActiveTextureARB(GL_TEXTURE0_ARB); if (GLEW_ARB_vertex_program) { @@ -163,7 +154,7 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, } } } - + glDrawElements(this->mode, this->indices, GL_UNSIGNED_SHORT, 0); glDisableClientState(GL_VERTEX_ARRAY); @@ -207,16 +198,6 @@ void RAS_StorageVBO::Exit() void RAS_StorageVBO::IndexPrimitives(RAS_MeshSlot& ms) { - IndexPrimitivesInternal(ms, false); -} - -void RAS_StorageVBO::IndexPrimitivesMulti(RAS_MeshSlot& ms) -{ - IndexPrimitivesInternal(ms, true); -} - -void RAS_StorageVBO::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi) -{ RAS_MeshSlot::iterator it; VBO *vbo; @@ -233,6 +214,6 @@ void RAS_StorageVBO::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi) vbo->UpdateData(); } - vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer, multi); + vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer); } } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h index f156722247c..f78faa97b16 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h @@ -42,7 +42,7 @@ public: VBO(RAS_DisplayArray *data, unsigned int indices); ~VBO(); - void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi); + void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer); void UpdateData(); void UpdateIndices(); @@ -73,7 +73,6 @@ public: virtual void Exit(); virtual void IndexPrimitives(RAS_MeshSlot& ms); - virtual void IndexPrimitivesMulti(RAS_MeshSlot& ms); virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;}; @@ -89,8 +88,6 @@ protected: std::map<RAS_DisplayArray*, class VBO*> m_vbo_lookup; - virtual void IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi); - #ifdef WITH_CXX_GUARDEDALLOC public: void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript deleted file mode 100644 index ce520df2a21..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python -Import ('env') - -sources = env.Glob('*.cpp') - -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -incs = [ - '.', - '#intern/container', - '#intern/guardedalloc', - '#intern/string', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - '#intern/moto/include', - '#source/blender/blenkernel', - '#source/blender/blenfont', - '#source/blender/blenlib', - '#source/blender/gpu', - '#source/blender/makesdna', - '#source/gameengine/BlenderRoutines', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Physics/common', - '#source/gameengine/Rasterizer', - '#source/gameengine/SceneGraph', - '#source/gameengine/Ketsji', - env['BF_OPENGL_INC'], - ] -incs = ' '.join(incs) - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -env.BlenderLib ( 'ge_oglrasterizer', Split(sources), Split(incs), defines = defs, libtype=['core','player'], priority=[350,75], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp index e6edc064200..2e176360d61 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.cpp +++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp @@ -66,10 +66,10 @@ const MT_Point3& RAS_TexVert::xyz() void RAS_TexVert::SetRGBA(const MT_Vector4& rgba) { unsigned char *colp = (unsigned char*) &m_rgba; - colp[0] = (unsigned char) (rgba[0] * 255.0); - colp[1] = (unsigned char) (rgba[1] * 255.0); - colp[2] = (unsigned char) (rgba[2] * 255.0); - colp[3] = (unsigned char) (rgba[3] * 255.0); + colp[0] = (unsigned char) (rgba[0] * 255.0f); + colp[1] = (unsigned char) (rgba[1] * 255.0f); + colp[2] = (unsigned char) (rgba[2] * 255.0f); + colp[3] = (unsigned char) (rgba[3] * 255.0f); } @@ -153,12 +153,12 @@ unsigned int RAS_TexVert::getUnit() const void RAS_TexVert::Transform(const MT_Matrix4x4& mat, const MT_Matrix4x4& nmat) { - SetXYZ((mat * MT_Vector4(m_localxyz[0], m_localxyz[1], m_localxyz[2], 1.0)).getValue()); - SetNormal((nmat * MT_Vector4(m_normal[0], m_normal[1], m_normal[2], 1.0)).getValue()); - SetTangent((nmat * MT_Vector4(m_tangent[0], m_tangent[1], m_tangent[2], 1.0)).getValue()); + SetXYZ((mat * MT_Vector4(m_localxyz[0], m_localxyz[1], m_localxyz[2], 1.0f)).getValue()); + SetNormal((nmat * MT_Vector4(m_normal[0], m_normal[1], m_normal[2], 1.0f)).getValue()); + SetTangent((nmat * MT_Vector4(m_tangent[0], m_tangent[1], m_tangent[2], 1.0f)).getValue()); } void RAS_TexVert::TransformUV(int index, const MT_Matrix4x4& mat) { - SetUV(index, (mat * MT_Vector4(m_uvs[index][0], m_uvs[index][1], 0.0, 1.0)).getValue()); + SetUV(index, (mat * MT_Vector4(m_uvs[index][0], m_uvs[index][1], 0.0f, 1.0f)).getValue()); } diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript deleted file mode 100644 index a643f46e39a..00000000000 --- a/source/gameengine/Rasterizer/SConscript +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('*.cpp') - -incs = [ - '.', - '#intern/guardedalloc', - '#intern/string', - '#intern/moto/include', - '#intern/container', - '#source/gameengine/BlenderRoutines', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - '#source/gameengine/Expressions', - '#source/gameengine/SceneGraph', - '#source/blender/blenlib', - '#source/blender/blenkernel', - '#source/blender/gpu', - '#source/blender/makesdna', - ] - -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -if env['WITH_BF_PYTHON']: - incs.extend(Split(env['BF_PYTHON_INC'])) - defs.append('WITH_PYTHON') - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - -env.BlenderLib('ge_rasterizer', sources, - includes=incs, defines=defs, - libtype=['core', 'player'], priority=[350, 70], - cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/SConscript b/source/gameengine/SConscript deleted file mode 100644 index ae1bb756f8e..00000000000 --- a/source/gameengine/SConscript +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -SConscript(['BlenderRoutines/SConscript', - 'Converter/SConscript', - 'Expressions/SConscript', #310 - 'GameLogic/SConscript', - 'Ketsji/SConscript', - 'Ketsji/KXNetwork/SConscript', - 'Network/SConscript', - 'Network/LoopBackNetwork/SConscript', - 'Physics/Dummy/SConscript', - 'Rasterizer/SConscript', - 'Rasterizer/RAS_OpenGLRasterizer/SConscript', - 'SceneGraph/SConscript', - ]) - -if env['WITH_BF_PYTHON']: - SConscript(['VideoTexture/SConscript']) - -if env['WITH_BF_PLAYER']: - SConscript(['GamePlayer/SConscript']) - -if env['WITH_BF_BULLET']: - SConscript(['Physics/Bullet/SConscript']) diff --git a/source/gameengine/SceneGraph/SConscript b/source/gameengine/SceneGraph/SConscript deleted file mode 100644 index f6e73a902a4..00000000000 --- a/source/gameengine/SceneGraph/SConscript +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('*.cpp') - -incs = [ - '.', - '#intern/moto/include', - ] - -defs = [] - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - incs.append('#intern/guardedalloc') - -if env['WITH_BF_PYTHON']: - defs.append('WITH_PYTHON') - incs.extend(Split(env['BF_PYTHON_INC'])) - -env.BlenderLib('ge_scenegraph', sources, incs, defs, libtype=['core', 'player'], priority=[325, 85], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/SceneGraph/SG_BBox.cpp b/source/gameengine/SceneGraph/SG_BBox.cpp index 0ecf6284a14..f9d83d37384 100644 --- a/source/gameengine/SceneGraph/SG_BBox.cpp +++ b/source/gameengine/SceneGraph/SG_BBox.cpp @@ -37,8 +37,8 @@ #include "SG_Node.h" SG_BBox::SG_BBox() : - m_min(0.0, 0.0, 0.0), - m_max(0.0, 0.0, 0.0) + m_min(0.0f, 0.0f, 0.0f), + m_max(0.0f, 0.0f, 0.0f) { } @@ -209,11 +209,11 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const { left.m_min = m_min; left.m_max[0] = m_max[0]; - left.m_max[1] = m_min[1] + sizey/2.0; + left.m_max[1] = m_min[1] + sizey/2.0f; left.m_max[2] = m_max[2]; right.m_min[0] = m_min[0]; - right.m_min[1] = m_min[1] + sizey/2.0; + right.m_min[1] = m_min[1] + sizey/2.0f; right.m_min[2] = m_min[2]; right.m_max = m_max; std::cout << "splity" << std::endl; @@ -222,11 +222,11 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const left.m_min = m_min; left.m_max[0] = m_max[0]; left.m_max[1] = m_max[1]; - left.m_max[2] = m_min[2] + sizez/2.0; + left.m_max[2] = m_min[2] + sizez/2.0f; right.m_min[0] = m_min[0]; right.m_min[1] = m_min[1]; - right.m_min[2] = m_min[2] + sizez/2.0; + right.m_min[2] = m_min[2] + sizez/2.0f; right.m_max = m_max; std::cout << "splitz" << std::endl; } @@ -234,11 +234,11 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const else { if (sizex > sizez) { left.m_min = m_min; - left.m_max[0] = m_min[0] + sizex/2.0; + left.m_max[0] = m_min[0] + sizex/2.0f; left.m_max[1] = m_max[1]; left.m_max[2] = m_max[2]; - right.m_min[0] = m_min[0] + sizex/2.0; + right.m_min[0] = m_min[0] + sizex/2.0f; right.m_min[1] = m_min[1]; right.m_min[2] = m_min[2]; right.m_max = m_max; @@ -248,11 +248,11 @@ void SG_BBox::split(SG_BBox &left, SG_BBox &right) const left.m_min = m_min; left.m_max[0] = m_max[0]; left.m_max[1] = m_max[1]; - left.m_max[2] = m_min[2] + sizez/2.0; + left.m_max[2] = m_min[2] + sizez/2.0f; right.m_min[0] = m_min[0]; right.m_min[1] = m_min[1]; - right.m_min[2] = m_min[2] + sizez/2.0; + right.m_min[2] = m_min[2] + sizez/2.0f; right.m_max = m_max; std::cout << "splitz" << std::endl; } diff --git a/source/gameengine/SceneGraph/SG_BBox.h b/source/gameengine/SceneGraph/SG_BBox.h index cd1c523ff40..3c524dc7f18 100644 --- a/source/gameengine/SceneGraph/SG_BBox.h +++ b/source/gameengine/SceneGraph/SG_BBox.h @@ -81,7 +81,7 @@ public: /** * Scales the bounding box about the optional point. */ - void scale(const MT_Vector3 &size, const MT_Point3 &point = MT_Point3(0.0, 0.0, 0.0)); + void scale(const MT_Vector3 &size, const MT_Point3 &point = MT_Point3(0.0f, 0.0f, 0.0f)); #endif SG_BBox transform(const MT_Transform &world) const; /** diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index f30c80da434..5cb75873237 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -43,18 +43,18 @@ SG_Spatial( ): SG_IObject(clientobj,clientinfo,callbacks), - m_localPosition(0.0,0.0,0.0), - m_localRotation(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0), - m_localScaling(1.f,1.f,1.f), + m_localPosition(0.0f,0.0f,0.0f), + m_localRotation(1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f), + m_localScaling(1.0f,1.0f,1.0f), - m_worldPosition(0.0,0.0,0.0), - m_worldRotation(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0), - m_worldScaling(1.f,1.f,1.f), + m_worldPosition(0.0f,0.0f,0.0f), + m_worldRotation(1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f), + m_worldScaling(1.0f,1.0f,1.0f), m_parent_relation (NULL), - m_bbox(MT_Point3(-1.0, -1.0, -1.0), MT_Point3(1.0, 1.0, 1.0)), - m_radius(1.0), + m_bbox(MT_Point3(-1.0f, -1.0f, -1.0f), MT_Point3(1.0f, 1.0f, 1.0f)), + m_radius(1.0f), m_modified(false), m_ogldirty(false) { diff --git a/source/gameengine/SceneGraph/SG_Tree.cpp b/source/gameengine/SceneGraph/SG_Tree.cpp index bef246533a6..87feb2c012a 100644 --- a/source/gameengine/SceneGraph/SG_Tree.cpp +++ b/source/gameengine/SceneGraph/SG_Tree.cpp @@ -41,7 +41,7 @@ SG_Tree::SG_Tree() : m_left(NULL), m_right(NULL), m_parent(NULL), - m_radius(0.0), + m_radius(0.0f), m_client_object(NULL) { } @@ -62,7 +62,7 @@ SG_Tree::SG_Tree(SG_Tree* left, SG_Tree* right) : m_bbox += m_right->m_bbox; m_right->m_parent = this; } - m_center = (m_bbox.m_min + m_bbox.m_max)/2.0; + m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f; m_radius = (m_bbox.m_max - m_bbox.m_min).length(); } @@ -73,7 +73,7 @@ SG_Tree::SG_Tree(SG_Node* client) : m_client_object(client) { m_bbox = SG_BBox(client->BBox(), client->GetWorldTransform()); - m_center = (m_bbox.m_min + m_bbox.m_max)/2.0; + m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f; m_radius = (m_bbox.m_max - m_bbox.m_min).length(); } @@ -162,7 +162,7 @@ void SG_Tree::SetLeft(SG_Tree *left) { m_left = left; m_bbox += left->m_bbox; - m_center = (m_bbox.m_min + m_bbox.m_max)/2.0; + m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f; m_radius = (m_bbox.m_max - m_bbox.m_min).length(); } @@ -170,7 +170,7 @@ void SG_Tree::SetRight(SG_Tree *right) { m_right = right; m_bbox += right->m_bbox; - m_center = (m_bbox.m_min + m_bbox.m_max)/2.0; + m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f; m_radius = (m_bbox.m_max - m_bbox.m_min).length(); } @@ -263,7 +263,7 @@ SG_Tree* SG_TreeFactory::MakeTreeDown(SG_BBox &bbox) return root; } - if (bbox.volume() < 1.0) + if (bbox.volume() < 1.0f) return MakeTreeUp(); SG_TreeFactory lefttree; diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript deleted file mode 100644 index dc708904309..00000000000 --- a/source/gameengine/VideoTexture/SConscript +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 -# of the License, or (at your option) any later version. -# -# 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, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -import sys - -Import ('env') - -sources = env.Glob('*.cpp') - -incs = [ - '.', - '#intern/container', - '#intern/ffmpeg', - '#intern/guardedalloc', - '#intern/string', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - '#intern/moto/include', - '#source/blender/blenkernel', - '#source/blender/blenlib', - '#source/blender/gpu', - '#source/blender/imbuf', - '#source/blender/makesdna', - '#source/blender/python', - '#source/gameengine/BlenderRoutines', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Ketsji', - '#source/gameengine/Rasterizer', - '#source/gameengine/SceneGraph', - '#source/blender/editors/include', - '#source/blender/python/generic', - '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - ] -incs = ' '.join(incs) - -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -if env['OURPLATFORM'] in ('win32-vc', 'win64-vc','win32-mingw', 'win64-mingw'): - if env['BF_DEBUG']: - defs.append('_DEBUG') - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -if env['WITH_BF_FFMPEG']: - defs.append('WITH_FFMPEG') - incs += ' ' + env['BF_FFMPEG_INC'] + ' ' + env['BF_PTHREADS_INC'] - -env.BlenderLib ( 'ge_videotex', sources, Split(incs), defs, libtype=['core','player'], priority=[340,205], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 0c7f3431a19..69566586019 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -34,7 +34,10 @@ // INT64_C fix for some linux machines (C99ism) #ifndef __STDC_CONSTANT_MACROS #define __STDC_CONSTANT_MACROS +#ifdef __STDC_CONSTANT_MACROS /* quiet warning */ #endif +#endif + #include <stdint.h> @@ -1024,11 +1027,11 @@ AVFrame *VideoFFmpeg::grabFrame(long position) AVFrame *input = m_frame; short counter = 0; - /* While the data is not read properly (png, tiffs, etc formats may need several pass)*/ - while ((input->data[0] == 0 && input->data[1] == 0 && input->data[2] == 0 && input->data[3] == 0) && counter < 10) { + /* If m_isImage, while the data is not read properly (png, tiffs, etc formats may need several pass), else don't need while loop*/ + do { avcodec_decode_video2(m_codecCtx, m_frame, &frameFinished, &packet); counter++; - } + } while ((input->data[0] == 0 && input->data[1] == 0 && input->data[2] == 0 && input->data[3] == 0) && counter < 10 && m_isImage); // remember dts to compute exact frame number dts = packet.dts; diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 8a8f7ebc5d5..fd10f8f106f 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -32,8 +32,6 @@ #include "KX_PythonInit.h" -#include <RAS_GLExtensionManager.h> - #include <RAS_IPolygonMaterial.h> //Old API |