Merge branch 'trunk' of https://github.com/lrre-foss/rnr into trunk
This commit is contained in:
commit
bd77eb29c3
|
|
@ -56,7 +56,7 @@ jobs:
|
|||
run: cp Content/win32_plugins.cfg build/dist/plugins.cfg && mkdir build/dist/plugins/ && cat build/dist/plugins.cfg | grep "Plugin=" | sed -e "s/Plugin=//" | xargs -I '{}' cp -v '/${{ matrix.sys }}/bin/{}.dll' build/dist/plugins/
|
||||
|
||||
- name: Add OGRE shaders
|
||||
run: mkdir build/dist/shaders && cp -R /${{ matrix.sys }}/share/OGRE/Media/Main/* build/dist/shaders && cp -R /${{ matrix.sys }}/share/OGRE/Media/RTShaderLib/* build/dist/shaders
|
||||
run: mkdir build/dist/shaders && cp -R /${{ matrix.sys }}/share/OGRE/Media/Main/* build/dist/shaders && cp -R /${{ matrix.sys }}/share/OGRE/Media/RTShaderLib/* build/dist/shaders && mv build/dist/shaders/GLSL/* build/dist/shaders && rm -rf build/dist/shaders/GLSL
|
||||
|
||||
- name: Add additional runtime dependencies
|
||||
run: ldd build/dist/*.exe | grep "=> /" | awk '{print $3}' | grep "${{ matrix.sys }}" | xargs -I '{}' cp -v '{}' build/dist
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
PluginFolder=plugins
|
||||
|
||||
Plugin=RenderSystem_GL
|
||||
Plugin=RenderSystem_GL3Plus
|
||||
Plugin=RenderSystem_GLES2
|
||||
Plugin=Plugin_ParticleFX
|
||||
|
|
@ -8,4 +7,4 @@ Plugin=Plugin_BSPSceneManager
|
|||
Plugin=Codec_STBI
|
||||
Plugin=Plugin_PCZSceneManager
|
||||
Plugin=Plugin_OctreeZone
|
||||
Plugin=Plugin_OctreeSceneManager
|
||||
Plugin=Plugin_OctreeSceneManager
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit e25de95445f2d635a125ab463426bb7fda017093
|
||||
Subproject commit 218159140c7d79ae745e646da721d12331f536f5
|
||||
|
|
@ -12,6 +12,8 @@ namespace RNR
|
|||
{
|
||||
private:
|
||||
QPointF last_position;
|
||||
QPoint grab_position;
|
||||
bool m_grabbed;
|
||||
OgreWidget* widget;
|
||||
bool reset;
|
||||
public:
|
||||
|
|
@ -21,5 +23,7 @@ namespace RNR
|
|||
void mouseEvent(QMouseEvent* e);
|
||||
|
||||
virtual void resetMouse();
|
||||
virtual void grab();
|
||||
virtual void ungrab();
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace RNR
|
|||
{
|
||||
last_position = QPointF();
|
||||
this->widget = widget;
|
||||
m_grabbed = false;
|
||||
}
|
||||
|
||||
void QtInputManager::keyEvent(QKeyEvent* e)
|
||||
|
|
@ -56,10 +57,30 @@ namespace RNR
|
|||
void QtInputManager::resetMouse()
|
||||
{
|
||||
widget->clearFocus();
|
||||
QPoint glob = widget->mapToGlobal(QPoint(widget->width()/2,widget->height()/2));
|
||||
QCursor::setPos(glob);
|
||||
last_position = QPoint(widget->width()/2,widget->height()/2);
|
||||
widget->setFocus();
|
||||
if(!m_grabbed)
|
||||
{
|
||||
QPoint glob = widget->mapToGlobal(QPoint(widget->width()/2,widget->height()/2));
|
||||
QCursor::setPos(glob);
|
||||
last_position = QPoint(widget->width()/2,widget->height()/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
QCursor::setPos(widget->mapToGlobal(grab_position));
|
||||
last_position = grab_position;
|
||||
}
|
||||
reset = true;
|
||||
widget->setFocus();
|
||||
}
|
||||
|
||||
void QtInputManager::grab()
|
||||
{
|
||||
grab_position = widget->mapFromGlobal(QCursor::pos());
|
||||
last_position = grab_position;
|
||||
m_grabbed = true;
|
||||
}
|
||||
|
||||
void QtInputManager::ungrab()
|
||||
{
|
||||
m_grabbed = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,9 +21,11 @@ qt_add_executable(Player ${SOURCE} ${HEADER})
|
|||
target_include_directories(Player PRIVATE Header)
|
||||
target_link_libraries(Player PRIVATE Common Engine)
|
||||
|
||||
set_target_properties(Player PROPERTIES
|
||||
OUTPUT_NAME "RNR.Player"
|
||||
|
||||
WIN32_EXECUTABLE ON
|
||||
MACOSX_BUNDLE ON
|
||||
)
|
||||
set_target_properties(Player PROPERTIES OUTPUT_NAME "RNR.Player")
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set_target_properties(Player PROPERTIES
|
||||
WIN32_EXECUTABLE ON
|
||||
MACOSX_BUNDLE ON
|
||||
)
|
||||
endif()
|
||||
|
|
@ -23,9 +23,11 @@ qt_add_executable(Studio ${SOURCE} ${HEADER})
|
|||
target_include_directories(Studio PRIVATE Header)
|
||||
target_link_libraries(Studio PRIVATE Common Engine)
|
||||
|
||||
set_target_properties(Studio PROPERTIES
|
||||
OUTPUT_NAME "RNR.Studio"
|
||||
|
||||
WIN32_EXECUTABLE ON
|
||||
MACOSX_BUNDLE ON
|
||||
)
|
||||
set_target_properties(Studio PROPERTIES OUTPUT_NAME "RNR.Studio")
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set_target_properties(Studio PROPERTIES
|
||||
WIN32_EXECUTABLE ON
|
||||
MACOSX_BUNDLE ON
|
||||
)
|
||||
endif()
|
||||
|
|
@ -30,9 +30,11 @@ int main(int argc, char** argv)
|
|||
window.updateTree(world->getDatamodel());
|
||||
window.ogreWidget->setWorld(world);
|
||||
|
||||
RNR::ComPlicitNgine* ngine = world->getComPlicitNgine();
|
||||
|
||||
while (window.isVisible())
|
||||
{
|
||||
window.statusBar()->showMessage(QString::asprintf("Dt=%f, Rt=%f, Pt=%f, FPS=%f, pFPS=%f", window.ogreWidget->delta, window.ogreWidget->render_time, window.ogreWidget->world->getPhysicsTime(), 1 / window.ogreWidget->delta, 1 / window.ogreWidget->world->getLastPhysicsDelta()));
|
||||
window.statusBar()->showMessage(QString::asprintf("Dt=%f, Rt=%f, Pt=%f, FPS=%f, pFPS=%f", window.ogreWidget->delta, window.ogreWidget->render_time, ngine->getPhysicsTime(), 1 / window.ogreWidget->delta, 1 / ngine->getLastPhysicsDelta()));
|
||||
app.processEvents();
|
||||
window.ogreWidget->render();
|
||||
world->update();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ add_library(Engine STATIC
|
|||
Header/App/V8/Tree/PVInstance.hpp
|
||||
Header/App/V8/Tree/ModelInstance.hpp
|
||||
Header/App/V8/World/World.hpp
|
||||
Header/App/V8/World/Weld.hpp
|
||||
Header/App/V8/World/ComPlicitNgine.hpp
|
||||
Header/App/CoordinateFrame.hpp
|
||||
Header/App/BrickColor.hpp
|
||||
Header/App/InputManager.hpp
|
||||
|
|
@ -64,6 +66,8 @@ add_library(Engine STATIC
|
|||
Source/App/BrickColor.cpp
|
||||
Source/App/InputManager.cpp
|
||||
Source/App/V8/World/World.cpp
|
||||
Source/App/V8/World/Weld.cpp
|
||||
Source/App/V8/World/ComPlicitNgine.cpp
|
||||
Source/Network/GUID.cpp
|
||||
Source/Network/Player.cpp
|
||||
Source/Network/Players.cpp
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ namespace RNR
|
|||
IInputManager();
|
||||
|
||||
virtual void resetMouse() {};
|
||||
virtual void grab() {};
|
||||
virtual void ungrab() {};
|
||||
|
||||
void setWorld(World* world) { m_world = world; world->setInputManager(this); }
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace RNR
|
||||
{
|
||||
class FaceInstance : public Instance, Ogre::ManualObject
|
||||
class FaceInstance : public Instance
|
||||
{
|
||||
private:
|
||||
NormalId m_face;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
#include <thread>
|
||||
#include <OGRE/Ogre.h>
|
||||
#include <App/V8/DataModel/PartInstance.hpp>
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include <map>
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
class World;
|
||||
|
||||
class ComPlicitNgine
|
||||
{
|
||||
std::thread m_physicsThread;
|
||||
Ogre::Timer* m_physicsTimer;
|
||||
float m_lastPhysicsDelta;
|
||||
float m_physicsTime;
|
||||
btDiscreteDynamicsWorld* m_dynamicsWorld;
|
||||
World* m_world;
|
||||
std::map<PartInstance*, btRigidBody*> m_physicsParts;
|
||||
|
||||
void thread();
|
||||
public:
|
||||
ComPlicitNgine(World* world);
|
||||
~ComPlicitNgine();
|
||||
|
||||
void updateTree();
|
||||
void updateTreeRender();
|
||||
|
||||
Ogre::Timer* getPhysicsTimer() { return m_physicsTimer; }
|
||||
float getLastPhysicsDelta() { return m_lastPhysicsDelta; }
|
||||
float getPhysicsTime() { return m_physicsTime; }
|
||||
|
||||
btRigidBody* getBody(PartInstance* part) { return m_physicsParts[part]; };
|
||||
|
||||
void registerPhysicsPart(PartInstance* partRegistered);
|
||||
void deletePhysicsPart(PartInstance* partDelete);
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
#include <App/V8/Tree/Instance.hpp>
|
||||
#include <App/V8/DataModel/PartInstance.hpp>
|
||||
#include <App/V8/World/ComPlicitNgine.hpp>
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
class Weld : public Instance
|
||||
{
|
||||
btRigidBody* m_aBody;
|
||||
PartInstance* m_aInstance;
|
||||
|
||||
btRigidBody* m_bBody;
|
||||
PartInstance* m_bInstance;
|
||||
|
||||
btFixedConstraint* m_constraint;
|
||||
public:
|
||||
Weld();
|
||||
~Weld();
|
||||
virtual std::string getClassName() { return "Weld"; }
|
||||
|
||||
void weld(PartInstance* a, PartInstance* b);
|
||||
void create();
|
||||
void destroy();
|
||||
|
||||
bool getBroken();
|
||||
};
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
#include <App/V8/DataModel/Camera.hpp>
|
||||
#include <App/V8/DataModel/RunService.hpp>
|
||||
#include <App/V8/DataModel/DataModel.hpp>
|
||||
#include <App/V8/World/ComPlicitNgine.hpp>
|
||||
#include <Network/Players.hpp>
|
||||
#include <App/GUI/TopMenuBar.hpp>
|
||||
#include <OGRE/Ogre.h>
|
||||
|
|
@ -14,7 +15,6 @@
|
|||
#include "LinearMath/btVector3.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
class IInputManager;
|
||||
|
|
@ -30,9 +30,6 @@ namespace RNR
|
|||
class World
|
||||
{
|
||||
private:
|
||||
std::thread m_physicsThread;
|
||||
Ogre::Timer* m_physicsTimer;
|
||||
|
||||
bool m_runPhysics;
|
||||
std::map<std::string, Instance*> m_refs;
|
||||
std::stack<WorldUndeserialized> m_undeserialized;
|
||||
|
|
@ -47,8 +44,7 @@ namespace RNR
|
|||
InstanceFactory* m_instanceFactory;
|
||||
IInputManager* m_inputManager;
|
||||
float m_lastDelta;
|
||||
float m_lastPhysicsDelta;
|
||||
float m_physicsTime;
|
||||
ComPlicitNgine* m_ngine;
|
||||
|
||||
void xmlAddItem(pugi::xml_node node, Instance* parent);
|
||||
public:
|
||||
|
|
@ -65,8 +61,9 @@ namespace RNR
|
|||
void update();
|
||||
|
||||
btDiscreteDynamicsWorld* getDynamicsWorld() { return m_dynamicsWorld; }
|
||||
ComPlicitNgine* getComPlicitNgine() { return m_ngine; }
|
||||
float getLastDelta() { return m_lastDelta; }
|
||||
float getLastPhysicsDelta() { return m_lastPhysicsDelta; }
|
||||
float getLastPhysicsDelta() { return m_ngine->getLastPhysicsDelta(); }
|
||||
DataModel* getDatamodel() { return m_datamodel; }
|
||||
void setInputManager(IInputManager* inputManager) { m_inputManager = inputManager; }
|
||||
IInputManager* getInputManager() { return m_inputManager; }
|
||||
|
|
@ -77,14 +74,8 @@ namespace RNR
|
|||
void setRunService(RunService* runService) { m_runService = runService; }
|
||||
Ogre::Root* getOgreRoot() { return m_ogreRoot; }
|
||||
Ogre::SceneManager* getOgreSceneManager() { return m_ogreSceneManager; }
|
||||
Ogre::Timer* getPhysicsTimer() { return m_physicsTimer; }
|
||||
float getPhysicsTime() { return m_physicsTime; }
|
||||
void setPhysicsTime(float newTime) { m_physicsTime = newTime; } // should only be used by physicsThread
|
||||
bool getPhysicsShouldBeRunningPleaseStopIfItIsStillRunning() { return m_runPhysics; }
|
||||
|
||||
void registerPhysicsPart(PartInstance* partRegistered);
|
||||
void deletePhysicsPart(PartInstance* partDelete);
|
||||
|
||||
Lock physicsIterateLock;
|
||||
};
|
||||
}
|
||||
|
|
@ -3,8 +3,17 @@
|
|||
|
||||
namespace RNR
|
||||
{
|
||||
// sub_60D330
|
||||
TopMenuBar::TopMenuBar(World* world)
|
||||
{
|
||||
/*
|
||||
if ( v30 )
|
||||
{
|
||||
*(float *)(v30 + 260) = 100.0;
|
||||
*(float *)(v30 + 264) = 20.0;
|
||||
}
|
||||
*/
|
||||
|
||||
m_world = world;
|
||||
|
||||
m_overlayManager = Ogre::OverlayManager::getSingletonPtr();
|
||||
|
|
@ -20,53 +29,53 @@ namespace RNR
|
|||
Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(m_overlayManager->createOverlayElement("Panel", "TopMenuBarPanel"));
|
||||
panel->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
panel->setPosition(0,0);
|
||||
panel->setDimensions(128 * 5, 20);
|
||||
panel->setDimensions(100 * 5, 20);
|
||||
panel->setMaterial(material);
|
||||
|
||||
Ogre::ColourValue text_color = Ogre::ColourValue(0.25, 0.25, 0.25);
|
||||
Ogre::ColourValue text_color = Ogre::ColourValue(0.25, 0.25, 0.25, 0.95);
|
||||
|
||||
Ogre::TextAreaOverlayElement* toolsTextArea = static_cast<Ogre::TextAreaOverlayElement*>(m_overlayManager->createOverlayElement("TextArea", "TopMenuBarTools"));
|
||||
toolsTextArea->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
toolsTextArea->setPosition(0, 0);
|
||||
toolsTextArea->setDimensions(128, 24);
|
||||
toolsTextArea->setDimensions(100, 20);
|
||||
toolsTextArea->setCaption("Tools");
|
||||
toolsTextArea->setCharHeight(24);
|
||||
toolsTextArea->setCharHeight(20);
|
||||
toolsTextArea->setFontName("ComicSans");
|
||||
toolsTextArea->setColour(text_color);
|
||||
|
||||
Ogre::TextAreaOverlayElement* insertTextArea = static_cast<Ogre::TextAreaOverlayElement*>(m_overlayManager->createOverlayElement("TextArea", "TopMenuBarInsert"));
|
||||
insertTextArea->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
insertTextArea->setPosition(128, 0);
|
||||
insertTextArea->setDimensions(128, 24);
|
||||
insertTextArea->setPosition(100, 0);
|
||||
insertTextArea->setDimensions(100, 20);
|
||||
insertTextArea->setCaption("Insert");
|
||||
insertTextArea->setCharHeight(24);
|
||||
insertTextArea->setCharHeight(20);
|
||||
insertTextArea->setFontName("ComicSans");
|
||||
insertTextArea->setColour(text_color);
|
||||
|
||||
Ogre::TextAreaOverlayElement* fullscreenTextArea = static_cast<Ogre::TextAreaOverlayElement*>(m_overlayManager->createOverlayElement("TextArea", "TopMenuBarFullscreen"));
|
||||
fullscreenTextArea->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
fullscreenTextArea->setPosition(128*2, 0);
|
||||
fullscreenTextArea->setDimensions(128, 24);
|
||||
fullscreenTextArea->setPosition(100*2, 0);
|
||||
fullscreenTextArea->setDimensions(100, 20);
|
||||
fullscreenTextArea->setCaption("Fullscreen");
|
||||
fullscreenTextArea->setCharHeight(24);
|
||||
fullscreenTextArea->setCharHeight(20);
|
||||
fullscreenTextArea->setFontName("ComicSans");
|
||||
fullscreenTextArea->setColour(text_color);
|
||||
|
||||
Ogre::TextAreaOverlayElement* helpTextArea = static_cast<Ogre::TextAreaOverlayElement*>(m_overlayManager->createOverlayElement("TextArea", "TopMenuBarHelp"));
|
||||
helpTextArea->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
helpTextArea->setPosition(128*3, 0);
|
||||
helpTextArea->setDimensions(128, 24);
|
||||
helpTextArea->setPosition(100*3, 0);
|
||||
helpTextArea->setDimensions(100, 20);
|
||||
helpTextArea->setCaption("Help...");
|
||||
helpTextArea->setCharHeight(24);
|
||||
helpTextArea->setCharHeight(20);
|
||||
helpTextArea->setFontName("ComicSans");
|
||||
helpTextArea->setColour(text_color);
|
||||
|
||||
Ogre::TextAreaOverlayElement* exitTextArea = static_cast<Ogre::TextAreaOverlayElement*>(m_overlayManager->createOverlayElement("TextArea", "TopMenuBarExit"));
|
||||
exitTextArea->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
exitTextArea->setPosition(128*4, 0);
|
||||
exitTextArea->setDimensions(128, 24);
|
||||
exitTextArea->setCaption("Exit");
|
||||
exitTextArea->setCharHeight(24);
|
||||
exitTextArea->setPosition(100*4, 0);
|
||||
exitTextArea->setDimensions(100, 20);
|
||||
exitTextArea->setCaption(" Exit"); // ... apparently spacing is how it was done in the original client
|
||||
exitTextArea->setCharHeight(20);
|
||||
exitTextArea->setFontName("ComicSans");
|
||||
exitTextArea->setColour(text_color);
|
||||
|
||||
|
|
@ -89,7 +98,7 @@ namespace RNR
|
|||
|
||||
m_playerPanel = static_cast<Ogre::OverlayContainer*>(m_overlayManager->createOverlayElement("Panel", "PlayerListPanel"));
|
||||
m_playerPanel->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
m_playerPanel->setDimensions(128, 20);
|
||||
m_playerPanel->setDimensions(100, 20);
|
||||
m_playerPanel->setMaterial(material);
|
||||
|
||||
m_playerList = static_cast<Ogre::TextAreaOverlayElement*>(m_overlayManager->createOverlayElement("TextArea", "PlayerListTextArea"));
|
||||
|
|
@ -97,7 +106,7 @@ namespace RNR
|
|||
m_playerList->setPosition(0, 0);
|
||||
m_playerList->setDimensions(1000, 1000);
|
||||
m_playerList->setCaption("Player List");
|
||||
m_playerList->setCharHeight(24);
|
||||
m_playerList->setCharHeight(20);
|
||||
m_playerList->setFontName("ComicSans");
|
||||
m_playerList->setColour(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
|
||||
|
||||
|
|
@ -146,14 +155,14 @@ namespace RNR
|
|||
else
|
||||
{
|
||||
m_playerPanel->setVisible(true);
|
||||
m_playerPanel->setPosition(m_overlayManager->getViewportWidth() - 128 - 5,5);
|
||||
m_playerPanel->setPosition(m_overlayManager->getViewportWidth() - 100 - 5,5);
|
||||
std::string player_list_text = "Player List\n";
|
||||
for(auto player : *player_list)
|
||||
{
|
||||
player_list_text += player->getName() + "\n";
|
||||
}
|
||||
m_playerList->setCaption(player_list_text);
|
||||
m_playerPanel->setDimensions(128, 20 * (player_list->size() + 1));
|
||||
m_playerPanel->setDimensions(100, 20 * (player_list->size() + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#include <App/Humanoid/Humanoid.hpp>
|
||||
#include <App/V8/World/World.hpp>
|
||||
#include <App/V8/World/Weld.hpp>
|
||||
#include <App/InputManager.hpp>
|
||||
|
||||
namespace RNR
|
||||
|
|
@ -24,7 +25,13 @@ namespace RNR
|
|||
|
||||
void Humanoid::buildJoints()
|
||||
{
|
||||
//
|
||||
if(getTorso() && getHead())
|
||||
{
|
||||
Weld* headWeld = new Weld();
|
||||
headWeld->weld(getTorso(), getHead());
|
||||
headWeld->create();
|
||||
headWeld->setParent(getTorso());
|
||||
}
|
||||
}
|
||||
|
||||
void Humanoid::checkForJointDeath()
|
||||
|
|
@ -118,7 +125,7 @@ namespace RNR
|
|||
move *= world->getLastDelta();
|
||||
|
||||
bool move_valid = true;
|
||||
|
||||
|
||||
// TODO: collision checking
|
||||
|
||||
if(!move_valid)
|
||||
|
|
|
|||
|
|
@ -91,6 +91,10 @@ namespace RNR
|
|||
|
||||
void IInputManager::mouseSecondaryState(bool down)
|
||||
{
|
||||
if(down)
|
||||
grab();
|
||||
else if(!down)
|
||||
ungrab();
|
||||
state.mouse_secondary = down;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
namespace RNR
|
||||
{
|
||||
FaceInstance::FaceInstance() : Ogre::ManualObject(Strings::random_hex(8))
|
||||
FaceInstance::FaceInstance()
|
||||
{
|
||||
setNode(world->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode());
|
||||
getNode()->attachObject(this);
|
||||
|
||||
|
||||
build();
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ namespace RNR
|
|||
child_node->setVisible(true);
|
||||
break;
|
||||
}
|
||||
world->registerPhysicsPart(part);
|
||||
world->getComPlicitNgine()->registerPhysicsPart(part);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ namespace RNR
|
|||
{
|
||||
PartInstance* part = dynamic_cast<PartInstance*>(childRemoved);
|
||||
if(part)
|
||||
world->deletePhysicsPart(part);
|
||||
world->getComPlicitNgine()->deletePhysicsPart(part);
|
||||
m_geomDirty = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,117 @@
|
|||
#include <App/V8/World/ComPlicitNgine.hpp>
|
||||
#include <App/V8/World/World.hpp>
|
||||
#include <Helpers/Bullet.hpp>
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
void ComPlicitNgine::thread()
|
||||
{
|
||||
float delta;
|
||||
float time;
|
||||
while(m_world->getPhysicsShouldBeRunningPleaseStopIfItIsStillRunning())
|
||||
{
|
||||
delta = m_physicsTimer->getMicroseconds() / 1000000.0;
|
||||
time += m_physicsTimer->getMilliseconds() / 1000.0;
|
||||
m_physicsTimer->reset();
|
||||
|
||||
m_lastPhysicsDelta = delta;
|
||||
m_physicsTime = time;
|
||||
|
||||
m_world->preStep();
|
||||
m_world->step(delta);
|
||||
|
||||
m_lastPhysicsDelta = delta;
|
||||
}
|
||||
}
|
||||
|
||||
ComPlicitNgine::ComPlicitNgine(World* world)
|
||||
{
|
||||
m_physicsTimer = new Ogre::Timer();
|
||||
m_physicsTime = 0.0;
|
||||
m_physicsThread = std::thread(&ComPlicitNgine::thread, this);
|
||||
m_dynamicsWorld = world->getDynamicsWorld();
|
||||
m_world = world;
|
||||
}
|
||||
|
||||
ComPlicitNgine::~ComPlicitNgine()
|
||||
{
|
||||
m_physicsThread.join();
|
||||
}
|
||||
|
||||
void ComPlicitNgine::updateTreeRender()
|
||||
{
|
||||
for(int j = m_dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--)
|
||||
{
|
||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[j];
|
||||
if(!obj->isActive())
|
||||
continue;
|
||||
PartInstance* part = (PartInstance*)obj->getUserPointer();
|
||||
part->updateMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
void ComPlicitNgine::updateTree()
|
||||
{
|
||||
for(int j = m_dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--)
|
||||
{
|
||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[j];
|
||||
if(!obj->isActive())
|
||||
continue;
|
||||
btRigidBody* body = btRigidBody::upcast(obj);
|
||||
btTransform trans;
|
||||
if(body && body->getMotionState())
|
||||
{
|
||||
body->getMotionState()->getWorldTransform(trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
trans = obj->getWorldTransform();
|
||||
}
|
||||
PartInstance* part = (PartInstance*)obj->getUserPointer();
|
||||
part->getCFrame().setPosition(Bullet::v3ToOgre(trans.getOrigin()));
|
||||
Ogre::Matrix3 partRot;
|
||||
Ogre::Quaternion transOgre = Bullet::qtToOgre(trans.getRotation());
|
||||
transOgre.ToRotationMatrix(partRot);
|
||||
part->getCFrame().setRotation(partRot);
|
||||
}
|
||||
}
|
||||
|
||||
void ComPlicitNgine::registerPhysicsPart(PartInstance* partRegistered)
|
||||
{
|
||||
btCollisionShape* partShape = new btBoxShape(Bullet::v3ToBullet(partRegistered->getSize() / 2.f));
|
||||
partShape->setUserPointer(partRegistered);
|
||||
|
||||
btTransform partTransform;
|
||||
partTransform.setIdentity();
|
||||
partTransform.setOrigin(Bullet::v3ToBullet(partRegistered->getPosition()));
|
||||
partTransform.setRotation(Bullet::qtToBullet(partRegistered->getRotation()));
|
||||
|
||||
btScalar mass = partRegistered->getSize().length();
|
||||
if(partRegistered->getAnchored())
|
||||
mass = 0;
|
||||
|
||||
btVector3 localInertia = btVector3(0,0,0);
|
||||
if(mass)
|
||||
partShape->calculateLocalInertia(mass, localInertia);
|
||||
|
||||
btDefaultMotionState* partMotionState = new btDefaultMotionState(partTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, partMotionState, partShape, localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
body->setUserPointer(partRegistered);
|
||||
|
||||
m_world->physicsIterateLock.lock();
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
m_world->physicsIterateLock.unlock();
|
||||
|
||||
m_physicsParts[partRegistered] = body;
|
||||
}
|
||||
|
||||
void ComPlicitNgine::deletePhysicsPart(PartInstance* partDelete)
|
||||
{
|
||||
btRigidBody* toDelete = m_physicsParts[partDelete];
|
||||
if(toDelete)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#include <App/V8/World/Weld.hpp>
|
||||
#include <App/V8/World/World.hpp>
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
Weld::Weld()
|
||||
{
|
||||
setName("Weld");
|
||||
}
|
||||
|
||||
Weld::~Weld()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void Weld::weld(PartInstance* a, PartInstance* b)
|
||||
{
|
||||
m_aInstance = a;
|
||||
m_bInstance = b;
|
||||
|
||||
m_aBody = world->getComPlicitNgine()->getBody(a);
|
||||
m_bBody = world->getComPlicitNgine()->getBody(b);
|
||||
}
|
||||
|
||||
void Weld::create()
|
||||
{
|
||||
if(!m_aBody || !m_bBody)
|
||||
return;
|
||||
|
||||
m_constraint = new btFixedConstraint(*m_aBody, *m_bBody, m_aBody->getWorldTransform(), m_bBody->getWorldTransform());
|
||||
}
|
||||
|
||||
void Weld::destroy()
|
||||
{
|
||||
delete m_constraint;
|
||||
}
|
||||
|
||||
bool Weld::getBroken()
|
||||
{
|
||||
if(!m_constraint)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,21 +12,6 @@
|
|||
|
||||
namespace RNR
|
||||
{
|
||||
void physicsThread(World* world)
|
||||
{
|
||||
float delta;
|
||||
float time;
|
||||
while(world->getPhysicsShouldBeRunningPleaseStopIfItIsStillRunning())
|
||||
{
|
||||
delta = world->getPhysicsTimer()->getMicroseconds() / 1000000.0;
|
||||
time += world->getPhysicsTimer()->getMilliseconds() / 1000.0;
|
||||
world->setPhysicsTime(time);
|
||||
world->getPhysicsTimer()->reset();
|
||||
world->preStep();
|
||||
world->step(delta);
|
||||
}
|
||||
}
|
||||
|
||||
World::World(Ogre::Root* ogre, Ogre::SceneManager* ogreSceneManager)
|
||||
{
|
||||
Instance::setWorld(this);
|
||||
|
|
@ -62,10 +47,7 @@ namespace RNR
|
|||
m_players = (Players*)m_datamodel->getService("Players");
|
||||
|
||||
m_runPhysics = true;
|
||||
m_physicsTimer = new Ogre::Timer();
|
||||
m_physicsThread = std::thread(physicsThread, this);
|
||||
m_physicsTime = 0.0;
|
||||
|
||||
m_ngine = new ComPlicitNgine(this);
|
||||
m_tmb = new TopMenuBar(this);
|
||||
|
||||
Camera* start_cam = new Camera();
|
||||
|
|
@ -76,7 +58,7 @@ namespace RNR
|
|||
World::~World()
|
||||
{
|
||||
m_runPhysics = false;
|
||||
m_physicsThread.join();
|
||||
delete m_ngine;
|
||||
}
|
||||
|
||||
void World::xmlAddItem(pugi::xml_node node, Instance* parent)
|
||||
|
|
@ -170,19 +152,8 @@ namespace RNR
|
|||
m_tmb->frame();
|
||||
m_lastDelta = timestep;
|
||||
if(m_runService && m_runService->getRunning() && !m_runService->getPaused())
|
||||
{
|
||||
physicsIterateLock.lock();
|
||||
for(int j = m_dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--)
|
||||
{
|
||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[j];
|
||||
if(!obj->isActive())
|
||||
continue;
|
||||
PartInstance* part = (PartInstance*)obj->getUserPointer();
|
||||
part->updateMatrix();
|
||||
}
|
||||
update();
|
||||
physicsIterateLock.unlock();
|
||||
}
|
||||
m_ngine->updateTreeRender();
|
||||
update();
|
||||
}
|
||||
|
||||
void World::preStep()
|
||||
|
|
@ -195,34 +166,9 @@ namespace RNR
|
|||
if(m_runService && m_runService->getRunning() && !m_runService->getPaused())
|
||||
{
|
||||
m_runService->step(timestep);
|
||||
m_dynamicsWorld->stepSimulation(timestep, 2);
|
||||
|
||||
physicsIterateLock.lock();
|
||||
for(int j = m_dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--)
|
||||
{
|
||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[j];
|
||||
if(!obj->isActive())
|
||||
continue;
|
||||
btRigidBody* body = btRigidBody::upcast(obj);
|
||||
btTransform trans;
|
||||
if(body && body->getMotionState())
|
||||
{
|
||||
body->getMotionState()->getWorldTransform(trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
trans = obj->getWorldTransform();
|
||||
}
|
||||
PartInstance* part = (PartInstance*)obj->getUserPointer();
|
||||
part->getCFrame().setPosition(Bullet::v3ToOgre(trans.getOrigin()));
|
||||
Ogre::Matrix3 partRot;
|
||||
Ogre::Quaternion transOgre = Bullet::qtToOgre(trans.getRotation());
|
||||
transOgre.ToRotationMatrix(partRot);
|
||||
part->getCFrame().setRotation(partRot);
|
||||
}
|
||||
physicsIterateLock.unlock();
|
||||
m_dynamicsWorld->stepSimulation(timestep, 1);
|
||||
m_ngine->updateTree();
|
||||
}
|
||||
m_lastPhysicsDelta = timestep;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
|
@ -231,34 +177,4 @@ namespace RNR
|
|||
m_workspace->buildGeom();
|
||||
}
|
||||
|
||||
void World::registerPhysicsPart(PartInstance* partRegistered)
|
||||
{
|
||||
btCollisionShape* partShape = new btBoxShape(Bullet::v3ToBullet(partRegistered->getSize() / 2.f));
|
||||
partShape->setUserPointer(partRegistered);
|
||||
|
||||
btTransform partTransform;
|
||||
partTransform.setIdentity();
|
||||
partTransform.setOrigin(Bullet::v3ToBullet(partRegistered->getPosition()));
|
||||
partTransform.setRotation(Bullet::qtToBullet(partRegistered->getRotation()));
|
||||
|
||||
btScalar mass = partRegistered->getSize().length();
|
||||
if(partRegistered->getAnchored())
|
||||
mass = 0;
|
||||
|
||||
btVector3 localInertia = btVector3(0,0,0);
|
||||
if(mass)
|
||||
partShape->calculateLocalInertia(mass, localInertia);
|
||||
|
||||
btDefaultMotionState* partMotionState = new btDefaultMotionState(partTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, partMotionState, partShape, localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
body->setUserPointer(partRegistered);
|
||||
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
}
|
||||
|
||||
void World::deletePhysicsPart(PartInstance* partDelete)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -53,6 +53,8 @@ namespace RNR
|
|||
Humanoid* character_humanoid = new Humanoid();
|
||||
character_humanoid->setParent(m_character);
|
||||
m_character->setParent(world->getWorkspace());
|
||||
|
||||
character_humanoid->buildJoints();
|
||||
|
||||
Camera* player_camera = world->getWorkspace()->getCurrentCamera();
|
||||
player_camera->setCFrame(CoordinateFrame());
|
||||
|
|
|
|||
Loading…
Reference in New Issue