Merge remote branch 'zini/next' into sound

This commit is contained in:
Chris Robinson 2012-03-28 06:27:34 -07:00
commit bedf56a237
26 changed files with 445 additions and 209 deletions

186
OFL.txt
View file

@ -1,93 +1,93 @@
Copyright (c) 2010, 2011 Georg Duffner (http://www.georgduffner.at)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Copyright (c) 2010, 2011 Georg Duffner (http://www.georgduffner.at)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View file

@ -89,7 +89,7 @@ target_link_libraries(openmw
${SOUND_INPUT_LIBRARY}
${BULLET_LIBRARIES}
${MYGUI_LIBRARIES}
MyGUI.OgrePlatform #TODO MyGUI ogre platform is not added by the find script
${MYGUI_PLATFORM_LIBRARIES}
components
)

View file

@ -15,6 +15,22 @@ using namespace MWGui;
HUD::HUD(int width, int height, int fpsLevel)
: Layout("openmw_hud_layout.xml")
, health(NULL)
, magicka(NULL)
, stamina(NULL)
, weapImage(NULL)
, spellImage(NULL)
, weapStatus(NULL)
, spellStatus(NULL)
, effectBox(NULL)
, effect1(NULL)
, minimap(NULL)
, compass(NULL)
, crosshair(NULL)
, fpsbox(NULL)
, fpscounter(NULL)
, trianglecounter(NULL)
, batchcounter(NULL)
{
setCoord(0,0, width, height);

View file

@ -7,6 +7,7 @@
#include "window_base.hpp"
#include "window_manager.hpp"
#undef MessageBox
namespace MWGui
{

View file

@ -13,9 +13,22 @@ const int StatsWindow::lineHeight = 18;
StatsWindow::StatsWindow (WindowManager& parWindowManager)
: WindowBase("openmw_stats_window_layout.xml", parWindowManager)
, skillAreaWidget(NULL)
, skillClientWidget(NULL)
, skillScrollerWidget(NULL)
, lastPos(0)
, clientHeight(0)
, majorSkills()
, minorSkills()
, miscSkills()
, skillValues()
, skillWidgetMap()
, factionWidgetMap()
, factions()
, birthSignId()
, reputation(0)
, bounty(0)
, skillWidgets()
{
setCoord(0,0,498, 342);

View file

@ -7,6 +7,9 @@
#include "../mwmechanics/stat.hpp"
#undef MYGUI_EXPORT
#define MYGUI_EXPORT
/*
This file contains various custom widgets used in OpenMW.
*/

View file

@ -22,15 +22,40 @@ using namespace MWGui;
WindowManager::WindowManager(MWWorld::Environment& environment,
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath)
: environment(environment)
: mGuiManager(NULL)
, environment(environment)
, hud(NULL)
, map(NULL)
, menu(NULL)
, stats(NULL)
, mMessageBoxManager(NULL)
, console(NULL)
, mJournal(NULL)
, dialogueWindow(nullptr)
, mCharGen(NULL)
, playerClass()
, playerName()
, playerRaceId()
, playerBirthSignId()
, playerAttributes()
, playerMajorSkills()
, playerMinorSkills()
, playerSkillValues()
, playerHealth()
, playerMagicka()
, playerFatigue()
, gui(NULL)
, mode(GM_Game)
, nextMode(GM_Game)
, needModeChange(false)
, garbageDialogs()
, shown(GW_ALL)
, allowed(newGame ? GW_None : GW_ALL)
, showFPSLevel(fpsLevel)
, mFPS(0.0f)
, mTriangleCount(0)
, mBatchCount(0)
{
showFPSLevel = fpsLevel;
// Set up the GUI system
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath);

View file

@ -8,6 +8,15 @@ using namespace Ogre;
using namespace MWRender;
using namespace NifOgre;
Actors::~Actors(){
std::map<MWWorld::Ptr, Animation*>::iterator it = mAllActors.begin();
for (; it != mAllActors.end(); ++it) {
delete it->second;
it->second = NULL;
}
}
void Actors::setMwRoot(Ogre::SceneNode* root){
mMwRoot = root;
}
@ -61,6 +70,7 @@ void Actors::insertCreature (const MWWorld::Ptr& ptr){
insertBegin(ptr, true, true);
CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend);
//mAllActors.insert(std::pair<MWWorld::Ptr, Animation*>(ptr,anim));
delete mAllActors[ptr];
mAllActors[ptr] = anim;
//mAllActors.push_back(&anim);*/
}

View file

@ -30,7 +30,7 @@ namespace MWRender{
public:
Actors(OEngine::Render::OgreRenderer& _rend, MWWorld::Environment& _env): mRend(_rend), mEnvironment(_env){}
~Actors(){}
~Actors();
void setMwRoot(Ogre::SceneNode* root);
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
void insertCreature (const MWWorld::Ptr& ptr);

View file

@ -4,7 +4,30 @@
namespace MWRender{
std::map<std::string, int> Animation::mUniqueIDs;
Animation::~Animation(){
Animation::Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend)
: insert(NULL)
, mRend(_rend)
, mEnvironment(_env)
, vecRotPos()
, shapeparts()
, time(0.0f)
, startTime(0.0f)
, stopTime(0.0f)
, animate(0)
, rindexI()
, tindexI()
, shapeNumber(0)
, shapeIndexI()
, shapes(NULL)
, entityparts()
, transformations(NULL)
, textmappings(NULL)
, base(NULL)
{
}
Animation::~Animation()
{
}
std::string Animation::getUniqueID(std::string mesh){

View file

@ -60,14 +60,14 @@ class Animation{
std::string getUniqueID(std::string mesh);
public:
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), animate(0){};
virtual void runAnimation(float timepassed) = 0;
void startScript(std::string groupname, int mode, int loops);
void stopScript();
virtual ~Animation();
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
virtual void runAnimation(float timepassed) = 0;
void startScript(std::string groupname, int mode, int loops);
void stopScript();
virtual ~Animation();
};
}
#endif
#endif

View file

@ -29,11 +29,6 @@ LocalMap::~LocalMap()
void LocalMap::deleteBuffers()
{
for (std::map<std::string, uint32*>::iterator it=mBuffers.begin();
it != mBuffers.end(); ++it)
{
delete it->second;
}
mBuffers.clear();
}
@ -202,16 +197,16 @@ void LocalMap::render(const float x, const float y,
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
// create a buffer to use for dynamic operations
uint32* buffer = new uint32[sFogOfWarResolution*sFogOfWarResolution];
std::vector<uint32> buffer;
buffer.resize(sFogOfWarResolution*sFogOfWarResolution);
// initialize to (0, 0, 0, 1)
uint32* pointer = buffer;
for (int p=0; p<sFogOfWarResolution*sFogOfWarResolution; ++p)
{
*(pointer+p) = (255 << 24);
buffer[p] = (255 << 24);
}
memcpy(tex2->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), buffer, sFogOfWarResolution*sFogOfWarResolution*4);
memcpy(tex2->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &buffer[0], sFogOfWarResolution*sFogOfWarResolution*4);
tex2->getBuffer()->unlock();
mBuffers[texture] = buffer;
@ -288,25 +283,23 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3&
{
// get its buffer
if (mBuffers.find(texName) == mBuffers.end()) return;
uint32* buffer = mBuffers[texName];
uint32* pointer = buffer;
int i=0;
for (int texV = 0; texV<sFogOfWarResolution; ++texV)
{
for (int texU = 0; texU<sFogOfWarResolution; ++texU)
{
float sqrDist = Math::Sqr(texU - u*sFogOfWarResolution) + Math::Sqr(texV - v*sFogOfWarResolution);
uint32 clr = *pointer;
uint32 clr = mBuffers[texName][i];
uint8 alpha = (clr >> 24);
alpha = std::min( alpha, (uint8) (std::max(0.f, std::min(1.f, (sqrDist/sqrExploreRadius)))*255) );
*((uint32*)pointer) = (alpha << 24);
mBuffers[texName][i] = (uint32) (alpha << 24);
// move to next texel
++pointer;
++i;
}
}
// copy to the texture
memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), buffer, sFogOfWarResolution*sFogOfWarResolution*4);
memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &mBuffers[texName][0], sFogOfWarResolution*sFogOfWarResolution*4);
tex->getBuffer()->unlock();
}
}

View file

@ -86,7 +86,7 @@ namespace MWRender
// a buffer for the "fog of war" texture of the current cell.
// interior cells could be divided into multiple textures,
// so we store in a map.
std::map <std::string, Ogre::uint32*> mBuffers;
std::map <std::string, std::vector<Ogre::uint32> > mBuffers;
void deleteBuffers();

View file

@ -254,7 +254,7 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
// Get a pointer to the vertex colour
ves_diffuse->baseVertexPointerToElement( pData, &currentVertex );
unsigned char alpha;
unsigned char alpha=0;
if (meshType == 0) alpha = i%2 ? 0 : 255; // this is a cylinder, so every second vertex belongs to the bottom-most row
else if (meshType == 1)
{
@ -292,10 +292,40 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock();
}
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env) :
mGlareFade(0), mGlareEnabled(false)
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env)
: mEnvironment(env)
, mHour(0.0f)
, mDay(0)
, mMonth(0)
, mSun(NULL)
, mSunGlare(NULL)
, mMasser(NULL)
, mSecunda(NULL)
, mViewport(NULL)
, mRootNode(NULL)
, mSceneMgr(NULL)
, mAtmosphereDay(NULL)
, mAtmosphereNight(NULL)
, mCloudMaterial()
, mAtmosphereMaterial()
, mCloudFragmentShader()
, mClouds()
, mNextClouds()
, mCloudBlendFactor(0.0f)
, mCloudOpacity(0.0f)
, mCloudSpeed(0.0f)
, mStarsOpacity(0.0f)
, mThunderOverlay(NULL)
, mThunderTextureUnit(NULL)
, mRemainingTransitionTime(0.0f)
, mGlareFade(0.0f)
, mEnabled(true)
, mGlareEnabled(true)
, mSunEnabled(true)
, mMasserEnabled(true)
, mSecundaEnabled(true)
{
mEnvironment = env;
mViewport = pCamera->getViewport();
mSceneMgr = pMwRoot->getCreator();
mRootNode = pCamera->getParentSceneNode()->createChildSceneNode();

View file

@ -213,7 +213,13 @@ void MpgSnd_Decoder::rewind()
}
}
MpgSnd_Decoder::MpgSnd_Decoder() : mSndFile(NULL), mMpgFile(NULL)
MpgSnd_Decoder::MpgSnd_Decoder()
: mSndInfo()
, mSndFile(NULL)
, mMpgFile(NULL)
, mDataStream()
, mChanConfig(ChannelConfig_Stereo)
, mSampleRate(0)
{
static bool initdone = false;
if(!initdone)

View file

@ -65,7 +65,7 @@ static ALenum getALFormat(ChannelConfig chans, SampleType type)
class OpenAL_SoundStream : public Sound
{
static const ALuint sNumBuffers = 6;
static const ALfloat sBufferLength = 0.125f;
static const ALfloat sBufferLength;
OpenAL_Output &mOutput;
@ -96,6 +96,8 @@ public:
bool process();
};
const ALfloat OpenAL_SoundStream::sBufferLength = 0.125f;
//
// A background streaming thread (keeps active streams processed)
//

View file

@ -24,7 +24,7 @@ namespace MWWorld
namespace MWSound
{
class Sound_Output;
class Sound_Decoder;
struct Sound_Decoder;
class Sound;
typedef boost::shared_ptr<Sound_Decoder> DecoderPtr;

View file

@ -9,9 +9,23 @@
SET( FFMPEG_FOUND "NO" )
FIND_PATH( FFMPEG_general_INCLUDE_DIR libavcodec/avcodec.h libavformat/avformat.h
HINTS
PATHS
/usr/include
/usr/local/include
/usr/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg/libavcodec
/usr/local/include/ffmpeg/libavcodec
/usr/include/libavcodec
/usr/local/include/libavcodec
)
FIND_PATH( FFMPEG_avcodec_INCLUDE_DIR avcodec.h
HINTS
PATHS
${FFMPEG_general_INCLUDE_DIR}/libavcodec
/usr/include
/usr/local/include
/usr/include/ffmpeg
@ -25,6 +39,7 @@ FIND_PATH( FFMPEG_avcodec_INCLUDE_DIR avcodec.h
FIND_PATH( FFMPEG_avformat_INCLUDE_DIR avformat.h
HINTS
PATHS
${FFMPEG_general_INCLUDE_DIR}/libavformat
/usr/include
/usr/local/include
/usr/include/ffmpeg
@ -35,7 +50,7 @@ FIND_PATH( FFMPEG_avformat_INCLUDE_DIR avformat.h
/usr/local/include/libavformat
)
set(FFMPEG_INCLUDE_DIR ${FFMPEG_avcodec_INCLUDE_DIR} ${FFMPEG_avformat_INCLUDE_DIR})
set(FFMPEG_INCLUDE_DIR ${FFMPEG_general_INCLUDE_DIR} ${FFMPEG_avcodec_INCLUDE_DIR} ${FFMPEG_avformat_INCLUDE_DIR})
IF( FFMPEG_INCLUDE_DIR )

View file

@ -19,57 +19,57 @@ include(FindPkgMacros)
IF (WIN32) #Windows
MESSAGE(STATUS "Looking for MyGUI")
SET(MYGUISDK $ENV{MYGUI_HOME})
SET(MYGUISDK $ENV{MYGUI_HOME})
IF (MYGUISDK)
findpkg_begin ( "MYGUI" )
findpkg_begin ( "MYGUI" )
MESSAGE(STATUS "Using MyGUI in OGRE SDK")
STRING(REGEX REPLACE "[\\]" "/" MYGUISDK "${MYGUISDK}" )
STRING(REGEX REPLACE "[\\]" "/" MYGUISDK "${MYGUISDK}" )
find_path ( MYGUI_INCLUDE_DIRS
MyGUI.h
"${MYGUISDK}/MyGUIEngine/include"
NO_DEFAULT_PATH )
find_path ( MYGUI_PLATFORM_INCLUDE_DIRS
MyGUI_OgrePlatform.h
"${MYGUISDK}/Platforms/Ogre/OgrePlatform/include"
NO_DEFAULT_PATH )
find_path ( MYGUI_INCLUDE_DIRS
MyGUI.h
"${MYGUISDK}/MyGUIEngine/include"
NO_DEFAULT_PATH )
SET ( MYGUI_LIB_DIR ${MYGUISDK}/*/lib )
find_library ( MYGUI_LIBRARIES_REL NAMES
MyGUIEngine.lib
MyGUI.OgrePlatform.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" release relwithdebinfo minsizerel )
find_path ( MYGUI_PLATFORM_INCLUDE_DIRS
MyGUI_OgrePlatform.h
"${MYGUISDK}/Platforms/Ogre/OgrePlatform/include"
NO_DEFAULT_PATH )
find_library ( MYGUI_LIBRARIES_DBG NAMES
MyGUIEngine_d.lib
MyGUI.OgrePlatform_d.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" debug )
SET ( MYGUI_LIB_DIR ${MYGUISDK}/*/lib )
find_library ( MYGUI_PLATFORM_LIBRARIES_REL NAMES
MyGUI.OgrePlatform.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" release relwithdebinfo minsizerel )
find_library ( MYGUI_LIBRARIES_REL NAMES
MyGUIEngine.lib
MyGUI.OgrePlatform.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" release relwithdebinfo minsizerel )
find_library ( MYGUI_PLATFORM_LIBRARIES_DBG NAMES
MyGUI.OgrePlatform_d.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" debug )
make_library_set ( MYGUI_LIBRARIES )
make_library_set ( MYGUI_PLATFORM_LIBRARIES )
MESSAGE ("${MYGUI_LIBRARIES}")
MESSAGE ("${MYGUI_PLATFORM_LIBRARIES}")
find_library ( MYGUI_LIBRARIES_DBG NAMES
MyGUIEngine_d.lib
MyGUI.OgrePlatform_d.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" debug )
findpkg_finish ( "MYGUI" )
find_library ( MYGUI_PLATFORM_LIBRARIES_REL NAMES
MyGUI.OgrePlatform.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" release relwithdebinfo minsizerel )
find_library ( MYGUI_PLATFORM_LIBRARIES_DBG NAMES
MyGUI.OgrePlatform_d.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" debug )
make_library_set ( MYGUI_LIBRARIES )
make_library_set ( MYGUI_PLATFORM_LIBRARIES )
MESSAGE ("${MYGUI_LIBRARIES}")
MESSAGE ("${MYGUI_PLATFORM_LIBRARIES}")
findpkg_finish ( "MYGUI" )
ENDIF (MYGUISDK)
IF (OGRESOURCE)
@ -87,9 +87,11 @@ ELSE (WIN32) #Unix
SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS})
SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR})
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "")
SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform")
ELSE (MYGUI_INCLUDE_DIRS)
FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI)
FIND_LIBRARY(MYGUI_LIBRARIES mygui PATHS /usr/lib /usr/local/lib)
SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform")
SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES})
STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}")
STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}")
@ -103,7 +105,7 @@ SEPARATE_ARGUMENTS(MYGUI_PLATFORM_LIBRARIES)
SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS} CACHE PATH "")
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "")
SET(MYGUI_LIBRARIES ${MYGUI_PLATFORM_LIBRARIES} CACHE STRING "")
SET(MYGUI_PLATFORM_LIBRARIES ${MYGUI_PLATFORM_LIBRARIES} CACHE STRING "")
SET(MYGUI_LIB_DIR ${MYGUI_LIB_DIR} CACHE PATH "")
IF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES)
@ -111,7 +113,7 @@ IF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES)
ENDIF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES)
IF (MYGUI_FOUND)
MARK_AS_ADVANCED(MYGUI_LIB_DIR)
MARK_AS_ADVANCED(MYGUI_LIB_DIR)
IF (NOT MYGUI_FIND_QUIETLY)
MESSAGE(STATUS " libraries : ${MYGUI_LIBRARIES} from ${MYGUI_LIB_DIR}")
MESSAGE(STATUS " includes : ${MYGUI_INCLUDE_DIRS}")
@ -122,4 +124,4 @@ ELSE (MYGUI_FOUND)
ENDIF (MYGUI_FIND_REQUIRED)
ENDIF (MYGUI_FOUND)
CMAKE_POLICY(POP)
CMAKE_POLICY(POP)

View file

@ -51,7 +51,11 @@ using namespace Mangle::VFS;
using namespace NifBullet;
//====================================================================================================
ManualBulletShapeLoader::~ManualBulletShapeLoader()
{
delete vfs;
}
Ogre::Matrix3 ManualBulletShapeLoader::getMatrix(Nif::Transformation* tr)
{
Ogre::Matrix3 rot(tr->rotation.v[0].array[0],tr->rotation.v[0].array[1],tr->rotation.v[0].array[2],
@ -135,7 +139,21 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,true);
}
currentShape = new btBvhTriangleMeshShape(mTriMesh,true);
struct TriangleMeshShape : public btBvhTriangleMeshShape
{
TriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression)
: btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression)
{
}
virtual ~TriangleMeshShape()
{
delete getTriangleInfoMap();
delete m_meshInterface;
}
};
currentShape = new TriangleMeshShape(mTriMesh,true);
cShape->Shape = currentShape;
}

View file

@ -69,7 +69,7 @@ class ManualBulletShapeLoader : public BulletShapeLoader
public:
ManualBulletShapeLoader():resourceGroup("General"){vfs = 0;}
virtual ~ManualBulletShapeLoader() {}
virtual ~ManualBulletShapeLoader();
void warn(std::string msg)
{

View file

@ -509,7 +509,8 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
datamod[index+1] = original.y;
datamod[index+2] = original.z;
}
vbuf->writeData(0, vbuf->getSizeInBytes(), datamod, false);
vbuf->writeData(0, vbuf->getSizeInBytes(), datamod, false);
delete [] datamod;
}
else
{
@ -550,6 +551,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
datamod[index+2] = original.z;
}
vbuf->writeData(0, vbuf->getSizeInBytes(), datamod, false);
delete [] datamod;
}
else
{
@ -601,6 +603,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
datamod[i + 1] =y;
}
vbuf->writeData(0, vbuf->getSizeInBytes(), datamod, false);
delete [] datamod;
}
else
vbuf->writeData(0, vbuf->getSizeInBytes(), data->uvlist.ptr, false);
@ -644,15 +647,13 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
index += 3;
}
ibuf->writeData(0, ibuf->getSizeInBytes(), datamod, false);
ibuf->writeData(0, ibuf->getSizeInBytes(), datamod, false);
delete [] datamod;
}
else
ibuf->writeData(0, ibuf->getSizeInBytes(), data->triangles.ptr, false);
ibuf->writeData(0, ibuf->getSizeInBytes(), data->triangles.ptr, false);
sub->indexData->indexBuffer = ibuf;
}
// Set material if one was given

View file

@ -22,6 +22,7 @@ Ogre::Resource(creator, name, handle, group, isManual, loader)
BulletShape::~BulletShape()
{
deleteShape(Shape);
}
// farm out to BulletShapeLoader

View file

@ -134,10 +134,15 @@ namespace Physic
RigidBody::RigidBody(btRigidBody::btRigidBodyConstructionInfo& CI,std::string name)
:btRigidBody(CI),mName(name)
: btRigidBody(CI)
, mName(name)
{
}
};
RigidBody::~RigidBody()
{
delete getMotionState();
}
@ -155,8 +160,7 @@ namespace Physic
// The actual physics solver
solver = new btSequentialImpulseConstraintSolver;
//TODO: memory leak?
btOverlappingPairCache* pairCache = new btSortedOverlappingPairCache();
pairCache = new btSortedOverlappingPairCache();
//pairCache->setInternalGhostPairCallback( new btGhostPairCallback() );
broadphase = new btDbvtBroadphase(pairCache);
@ -173,6 +177,7 @@ namespace Physic
mShapeLoader = shapeLoader;
isDebugCreated = false;
mDebugDrawer = NULL;
}
void PhysicEngine::createDebugRendering()
@ -202,11 +207,41 @@ namespace Physic
PhysicEngine::~PhysicEngine()
{
RigidBodyContainer::iterator rb_it = RigidBodyMap.begin();
for (; rb_it != RigidBodyMap.end(); ++rb_it)
{
if (rb_it->second != NULL)
{
dynamicsWorld->removeRigidBody(rb_it->second);
delete rb_it->second;
rb_it->second = NULL;
}
}
PhysicActorContainer::iterator pa_it = PhysicActorMap.begin();
for (; pa_it != PhysicActorMap.end(); ++pa_it)
{
if (pa_it->second != NULL)
{
dynamicsWorld->removeCollisionObject(pa_it->second->externalGhostObject);
dynamicsWorld->removeCollisionObject(pa_it->second->internalGhostObject);
dynamicsWorld->removeAction(pa_it->second->mCharacter);
delete pa_it->second;
pa_it->second = NULL;
}
}
delete mDebugDrawer;
delete dynamicsWorld;
delete solver;
delete collisionConfiguration;
delete dispatcher;
delete broadphase;
delete pairCache;
delete mShapeLoader;
}
@ -239,32 +274,39 @@ namespace Physic
dynamicsWorld->addRigidBody(body,COL_WORLD,COL_NOTHING);
}
body->setActivationState(DISABLE_DEACTIVATION);
RigidBody* oldBody = RigidBodyMap[body->mName];
if (oldBody != NULL)
{
dynamicsWorld->removeRigidBody(oldBody);
delete oldBody;
}
RigidBodyMap[body->mName] = body;
}
void PhysicEngine::removeRigidBody(std::string name)
{
std::map<std::string,RigidBody*>::iterator it = RigidBodyMap.find(name);
RigidBodyContainer::iterator it = RigidBodyMap.find(name);
if (it != RigidBodyMap.end() )
{
RigidBody* body = it->second;
if(body != NULL)
{
// broadphase->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(body->getBroadphaseProxy(),dispatcher);
/*std::map<std::string,PhysicActor*>::iterator it2 = PhysicActorMap.begin();
/*PhysicActorContainer::iterator it2 = PhysicActorMap.begin();
for(;it2!=PhysicActorMap.end();it++)
{
it2->second->internalGhostObject->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(body->getBroadphaseProxy(),dispatcher);
it2->second->externalGhostObject->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(body->getBroadphaseProxy(),dispatcher);
}*/
dynamicsWorld->removeRigidBody(RigidBodyMap[name]);
dynamicsWorld->removeRigidBody(body);
}
}
}
void PhysicEngine::deleteRigidBody(std::string name)
{
std::map<std::string,RigidBody*>::iterator it = RigidBodyMap.find(name);
RigidBodyContainer::iterator it = RigidBodyMap.find(name);
if (it != RigidBodyMap.end() )
{
RigidBody* body = it->second;
@ -293,6 +335,10 @@ namespace Physic
void PhysicEngine::addCharacter(std::string name)
{
// Remove character with given name, so we don't make memory
// leak when character would be added twice
removeCharacter(name);
PhysicActor* newActor = new PhysicActor(name);
dynamicsWorld->addCollisionObject( newActor->externalGhostObject, COL_ACTOR_EXTERNAL, COL_WORLD |COL_ACTOR_EXTERNAL );
dynamicsWorld->addCollisionObject( newActor->internalGhostObject, COL_ACTOR_INTERNAL, COL_WORLD |COL_ACTOR_INTERNAL );
@ -303,7 +349,7 @@ namespace Physic
void PhysicEngine::removeCharacter(std::string name)
{
//std::cout << "remove";
std::map<std::string,PhysicActor*>::iterator it = PhysicActorMap.find(name);
PhysicActorContainer::iterator it = PhysicActorMap.find(name);
if (it != PhysicActorMap.end() )
{
PhysicActor* act = it->second;
@ -311,7 +357,7 @@ namespace Physic
{
/*broadphase->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(act->externalGhostObject->getBroadphaseHandle(),dispatcher);
broadphase->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(act->internalGhostObject->getBroadphaseHandle(),dispatcher);
std::map<std::string,PhysicActor*>::iterator it2 = PhysicActorMap.begin();
PhysicActorContainer::iterator it2 = PhysicActorMap.begin();
for(;it2!=PhysicActorMap.end();it++)
{
it->second->internalGhostObject->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(act->externalGhostObject->getBroadphaseHandle(),dispatcher);

View file

@ -42,6 +42,8 @@ namespace Physic
:btPairCachingGhostObject(),mName(name)
{
}
virtual ~PairCachingGhostObject(){}
std::string mName;
};
@ -106,6 +108,7 @@ namespace Physic
{
public:
RigidBody(btRigidBody::btRigidBodyConstructionInfo& CI,std::string name);
virtual ~RigidBody();
std::string mName;
//is this body used for raycasting only?
@ -208,6 +211,7 @@ namespace Physic
std::list<PhysicEvent> PEventList;
//Bullet Stuff
btOverlappingPairCache* pairCache;
btBroadphaseInterface* broadphase;
btDefaultCollisionConfiguration* collisionConfiguration;
btSequentialImpulseConstraintSolver* solver;
@ -217,8 +221,11 @@ namespace Physic
//the NIF file loader.
BulletShapeLoader* mShapeLoader;
std::map<std::string,RigidBody*> RigidBodyMap;
std::map<std::string,PhysicActor*> PhysicActorMap;
typedef std::map<std::string,RigidBody*> RigidBodyContainer;
RigidBodyContainer RigidBodyMap;
typedef std::map<std::string, PhysicActor*> PhysicActorContainer;
PhysicActorContainer PhysicActorMap;
//debug rendering
BtOgre::DebugDrawer* mDebugDrawer;

View file

@ -44,27 +44,51 @@ namespace Render
Ogre::SceneManager *mScene;
Ogre::Camera *mCamera;
Ogre::Viewport *mView;
#ifdef ENABLE_PLUGIN_CgProgramManager
#ifdef ENABLE_PLUGIN_CgProgramManager
Ogre::CgPlugin* mCgPlugin;
#endif
#ifdef ENABLE_PLUGIN_OctreeSceneManager
#endif
#ifdef ENABLE_PLUGIN_OctreeSceneManager
Ogre::OctreePlugin* mOctreePlugin;
#endif
#ifdef ENABLE_PLUGIN_ParticleFX
#endif
#ifdef ENABLE_PLUGIN_ParticleFX
Ogre::ParticleFXPlugin* mParticleFXPlugin;
#endif
#ifdef ENABLE_PLUGIN_GL
#endif
#ifdef ENABLE_PLUGIN_GL
Ogre::GLPlugin* mGLPlugin;
#endif
#ifdef ENABLE_PLUGIN_Direct3D9
#endif
#ifdef ENABLE_PLUGIN_Direct3D9
Ogre::D3D9Plugin* mD3D9Plugin;
#endif
#endif
Fader* mFader;
bool logging;
public:
OgreRenderer()
: mRoot(NULL), mWindow(NULL), mScene(NULL), mFader(NULL) {}
: mRoot(NULL)
, mWindow(NULL)
, mScene(NULL)
, mCamera(NULL)
, mView(NULL)
#ifdef ENABLE_PLUGIN_CgProgramManager
, mCgPlugin(NULL)
#endif
#ifdef ENABLE_PLUGIN_OctreeSceneManager
, mOctreePlugin(NULL)
#endif
#ifdef ENABLE_PLUGIN_ParticleFX
, mParticleFXPlugin(NULL)
#endif
#ifdef ENABLE_PLUGIN_GL
, mGLPlugin(NULL)
#endif
#ifdef ENABLE_PLUGIN_Direct3D9
, mD3D9Plugin(NULL)
#endif
, mFader(NULL)
, logging(false)
{
}
~OgreRenderer() { cleanup(); }
/** Configure the renderer. This will load configuration files and