Skip to content

Commit

Permalink
The version at the end of the project.
Browse files Browse the repository at this point in the history
  • Loading branch information
VirFunc committed Oct 31, 2019
1 parent 1383ab8 commit af7ecaf
Show file tree
Hide file tree
Showing 46 changed files with 1,246 additions and 1,789 deletions.
56 changes: 35 additions & 21 deletions MixEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Mx/Audio/MxAudio.hpp"
#include "Mx/Physics/MxPhysicsWorld.h"
#include "Mx/Vulkan/Shader/MxVkStandardShader.h"
#include "Mx/GUI/MxUi.h"
#include "Mx/GUI/MxGUi.h"
#include "Mx/Resource/MxResourceLoader.h"
#include "Mx/Graphics/MxGraphics.h"
#include "Mx/Scene/MxSceneManager.h"
Expand Down Expand Up @@ -55,11 +55,9 @@ namespace Mix {
while (!mQuit) {
/*awake();
init();*/

while (mRunning) {
Platform::Update();
Time::Tick();

Platform::Update();
Time::Tick();
if (mRunning) {
// Limit FPS if limit was set.
if (mFPSLimit > 0) {
float currentTime = Time::TotalTime();
Expand All @@ -84,12 +82,24 @@ namespace Mix {
startTp = Time::RealTime();
mFrameCount = 0u;
}
Window::Get()->setTitle(std::to_string(mFramePerSecond));
//Window::Get()->setTitle(std::to_string(mFramePerSecond));

//auto start = Time::RealTime();
update();
//Log::Info("Update %1%", Time::RealTime() - start);

//start = Time::RealTime();
lateUpdate();
//Log::Info("lateUpdate %1%", Time::RealTime() - start);

//start = Time::RealTime();
render();
//Log::Info("render %1%", Time::RealTime() - start);

//start = Time::RealTime();
postRender();
//Log::Info("postRender %1%", Time::RealTime() - start);
//Log::Info("");
}
}
}
Expand All @@ -112,16 +122,6 @@ namespace Mix {
mApp->onMainSceneCreated();
}

/*void MixEngine::awake() {
mApp->onAwake();
mModuleHolder.get<SceneManager>()->sceneAwake();
}
void MixEngine::init() {
mApp->onInit();
mModuleHolder.get<SceneManager>()->sceneInit();
}*/

void MixEngine::update() {
mApp->onUpdate();
mModuleHolder.get<Physics::World>()->sync(Time::FixedDeltaTime(), Time::SmoothingFactor());
Expand Down Expand Up @@ -151,15 +151,26 @@ namespace Mix {
}

void MixEngine::loadModule() {
mModuleHolder.add<Window>("Mix Engine Demo", Vector2i{ 1024, 760 }, WindowFlag::VULKAN | WindowFlag::SHOWN)->load();
SDL_Rect rect;
SDL_GetDisplayBounds(0, &rect);

mModuleHolder.add<Window>("Mix Engine Demo", Vector2i{ rect.w * 0.4f, rect.h * 0.8f }, WindowFlag::Vulkan | WindowFlag::Shown)->load();
mModuleHolder.add<Input>()->load();
mModuleHolder.add<Audio::Core>()->load();
mModuleHolder.add<Physics::World>()->load();
mModuleHolder.add<Graphics>()->load();
mModuleHolder.add<GUI>()->load();
mModuleHolder.add<ResourceLoader>()->load();
mModuleHolder.add<SceneObjectManager>()->load();
mModuleHolder.add<SceneManager>()->load();

std::string n = mApp->getAppName();
Version v = mApp->getAppVersion();
std::string title = Utils::StringFormat("%1% V %2%.%3%.%4%",
mApp->getAppName(),
v.getMajor(), v.getMinor(), v.getPatch());
Window::Get()->setTitle(title);

mApp->onModuleLoaded();
}

Expand All @@ -168,7 +179,7 @@ namespace Mix {
for (auto m : modules)
m->init();

mApp->onMoudleInitialized();
mApp->onModuleInitialized();
}

void MixEngine::onQuitRequested() {
Expand All @@ -182,10 +193,13 @@ namespace Mix {
#ifdef MX_ENABLE_PHYSICS_DEBUG_DRAW_
mModuleHolder.get<Physics::World>()->render();
#endif

mModuleHolder.get<GUI>()->beginGUI();
mApp->onGUI();
mModuleHolder.get<GUI>()->endGUI();
mModuleHolder.get<GUI>()->update();
mModuleHolder.get<Graphics>()->update();
mModuleHolder.get<Graphics>()->render();
}
}

void MixEngine::postRender() {
mApp->onPostRender();
Expand Down
5 changes: 5 additions & 0 deletions MixEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace Mix {

int execute(std::shared_ptr<ApplicationBase> _app);

/**
* \brief Call to issue a request for the application to close. \n
* This will eventually trigger an quit event and onQuitRequested() will be called.
* \note ONLY call this after startUp() has been called
*/
void requestQuit();

private:
Expand Down
8 changes: 4 additions & 4 deletions Mx/Component/RigidBody/MxRigidBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace Mix {
mWorld(nullptr) {
ltm.addShape(mShape);
mRigidBody = CreateBtRb(_info);
mRigidBody->setUserPointer(this);
mRigidBody->setUserPointer(&mThisHandle);
}

RigidBody::RigidBody(const Physics::RigidBodyConstructionInfo& _info,
Expand All @@ -57,7 +57,7 @@ namespace Mix {
mWorld(nullptr) {
ltm.addShape(mShape);
mRigidBody = CreateBtRb(_info);
mRigidBody->setUserPointer(this);
mRigidBody->setUserPointer(&mThisHandle);
}

RigidBody::~RigidBody() {
Expand Down Expand Up @@ -170,8 +170,8 @@ namespace Mix {
motionstate,
_info.shape,
inertia);
info.m_linearSleepingThreshold = .02; // default to .8
info.m_angularSleepingThreshold = .02; // default to 1
info.m_linearSleepingThreshold = .01; // default to .8
info.m_angularSleepingThreshold = .01; // default to 1
_info.furtherSetup(info);
return new btRigidBody(info);
}
Expand Down
7 changes: 4 additions & 3 deletions Mx/Component/RigidBody/MxRigidBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define MX_RIGID_BODY_H_

#include "../Behaviour/MxBehaviour.h"
#include "../../Definitions/MxDefinitions.h"
#include <bullet3/btBulletDynamicsCommon.h>
#include <boost/signals2.hpp>
#include <tuple>
Expand All @@ -26,7 +27,7 @@ namespace Mix {
friend Physics::World;

public:
using Signal = boost::signals2::signal<void(RigidBody*)>;
using Signal = boost::signals2::signal<void(HRigidBody)>;
using Slot = Signal::slot_type;

/** @note Default ctor is for RTTI. DO NOT use this ctor. */
Expand Down Expand Up @@ -127,8 +128,8 @@ namespace Mix {
btDiscreteDynamicsWorld* mWorld;

Signal mEnterSignal, mExitSignal;
void onTriggerEnter(RigidBody* _other) { mEnterSignal(_other); }
void onTriggerExit(RigidBody* _other) { mExitSignal(_other); }
void onTriggerEnter(HRigidBody _other) { mEnterSignal(_other); }
void onTriggerExit(HRigidBody _other) { mExitSignal(_other); }

/** @brief A utility function to create btRigidBody from RigidBodyConstructionInfo */
static btRigidBody* CreateBtRb(const Physics::RigidBodyConstructionInfo& _info);
Expand Down
6 changes: 5 additions & 1 deletion Mx/Component/Transform/MxTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ namespace Mix {
setRotation(Quaternion::LookRotation(dir, _worldUp));
}

void Transform::updateLocalToWorldMatrix() const {
void Transform::forceUpdate() {
updateLocalToWorldMatrix();
}

void Transform::updateLocalToWorldMatrix() const {
if (mChanged) {
mLocalToWorld = Matrix4::TRS(mPosition, mQuat, mScale);
if (mGameObject && mGameObject->getParent())
Expand Down
2 changes: 2 additions & 0 deletions Mx/Component/Transform/MxTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ namespace Mix {
lookAt(_target.getPosition(), _worldUp);
}

void forceUpdate();

private:
Vector3f mPosition;
Quaternion mQuat;
Expand Down
10 changes: 10 additions & 0 deletions Mx/Definitions/MxCommonType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,13 @@ const char* Mix::ToString(RenderType e) {
default: return "Unknown";
}
}

const char* Mix::ToString(GPUBufferUsage e) {
switch (e) {
case GPUBufferUsage::Static: return "Static";
case GPUBufferUsage::Dynamic: return "Dynamic";
case GPUBufferUsage::Stream: return "Stream";
case GPUBufferUsage::Transfer: return "Transfer";
default: return "Unknown";
}
}
15 changes: 15 additions & 0 deletions Mx/Definitions/MxCommonType.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ namespace Mix {
};

const char* ToString(RenderType e);


/**
* \brief Enumeration that represents the usage of a gpu buffer and usually makes the storage location of GPU buffer different.
*/
enum class GPUBufferUsage {
Static = 0x0001,
Dynamic = 0x0002,
Stream = 0x0004,
Transfer = 0x0008
};

const char* ToString(GPUBufferUsage e);


}

#endif
4 changes: 2 additions & 2 deletions Mx/Engine/MxPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ namespace Mix {
struct PFMouseMoveEventData {
Vector2i pos;
Vector2i relativePos;
uint8_t state = 0; /**< Test with PFMpuseButton */
uint8_t state = 0; /**< Test with PFMouseButton */
};

struct PFMouseButtonEventData {
uint8_t state = 0; /**< Test with PFButtonState */
uint8_t clicks = 0;
ButtonCode button; /**< Test with PFMouseButton, only one bit will be set */
ButtonCode button;
Vector2i pos;
};

Expand Down
Loading

0 comments on commit af7ecaf

Please sign in to comment.