Better way to import vrms; fix physics in editor
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include "AppModule.h"
|
||||
#include "EditorGizmoModule.h"
|
||||
#include "EditorInputModule.h"
|
||||
#include "PhysicsModule.h"
|
||||
#include "physics.h"
|
||||
#include "sound.h"
|
||||
|
||||
class App;
|
||||
@@ -588,10 +590,14 @@ public:
|
||||
{
|
||||
}
|
||||
bool switchWindow = false;
|
||||
void createContent()
|
||||
JoltPhysicsWrapper *mJolt;
|
||||
void createContent()
|
||||
{
|
||||
int i;
|
||||
sky = new SkyBoxRenderer(mEditorNormalScene.getSceneManager());
|
||||
mJolt = new JoltPhysicsWrapper(
|
||||
mEditorNormalScene.getSceneManager(),
|
||||
mEditorNormalScene.mCameraNode);
|
||||
sky = new SkyBoxRenderer(mEditorNormalScene.getSceneManager());
|
||||
bool drawFirst = true;
|
||||
uint8_t renderQueue = drawFirst ?
|
||||
Ogre::RENDER_QUEUE_SKIES_EARLY :
|
||||
@@ -611,8 +617,12 @@ public:
|
||||
mEditorNormalScene.mScnMgr,
|
||||
/*mDynWorld.get(), */ mEditorNormalScene.mCameraNode,
|
||||
mEditorNormalScene.mCamera, getRenderWindow());
|
||||
ECS::get().import <ECS::EditorGizmoModule>();
|
||||
ECS::get().import <ECS::EditorInputModule>();
|
||||
ECS::get().import <ECS::PhysicsModule>();
|
||||
ECS::get().import <ECS::EditorGizmoModule>();
|
||||
ECS::get().import <ECS::EditorInputModule>();
|
||||
ECS::Physics &ph = ECS::get().ensure<ECS::Physics>();
|
||||
ph.physics = mJolt;
|
||||
ECS::modified<ECS::Physics>();
|
||||
ECS::get().set<ECS::RenderWindow>(
|
||||
{ getRenderWindow(), getDisplayDPI() });
|
||||
ECS::get()
|
||||
|
||||
@@ -593,13 +593,13 @@ CharacterAIModule::CharacterAIModule(flecs::world &ecs)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
std::cout << "NPC: " << plans.first;
|
||||
std::cout << " Plans: " << plans.second.size();
|
||||
// std::cout << "NPC: " << plans.first;
|
||||
// std::cout << " Plans: " << plans.second.size();
|
||||
for (const auto &plan : plans.second) {
|
||||
struct PlanExec pexec;
|
||||
if (plan.plan.size() == 0)
|
||||
continue;
|
||||
std::cout << " Goal: ";
|
||||
// std::cout << " Goal: ";
|
||||
plan.goal->goal.dump_bits();
|
||||
for (const auto &action : plan.plan) {
|
||||
ActionExec::PlanExecData data({
|
||||
@@ -631,9 +631,9 @@ CharacterAIModule::CharacterAIModule(flecs::world &ecs)
|
||||
pexec.action_exec
|
||||
.push_back(e);
|
||||
} else {
|
||||
std::cout
|
||||
<< action->get_name()
|
||||
<< " ";
|
||||
// std::cout
|
||||
// << action->get_name()
|
||||
// << " ";
|
||||
ActionExec *e = OGRE_NEW
|
||||
ActionExecCommon(
|
||||
data,
|
||||
@@ -641,13 +641,13 @@ CharacterAIModule::CharacterAIModule(flecs::world &ecs)
|
||||
pexec.action_exec
|
||||
.push_back(e);
|
||||
}
|
||||
std::cout << action->get_name()
|
||||
<< " ";
|
||||
// std::cout << action->get_name()
|
||||
// << " ";
|
||||
}
|
||||
plan_exec[plans.first] = pexec;
|
||||
break;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
//std::cout << std::endl;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -107,7 +107,6 @@ void setupExteriorScene(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
|
||||
ecs.set<EngineData>({ scnMgr, 0.0f, 5.0f, (int)window->getWidth(),
|
||||
(int)window->getHeight(), false });
|
||||
ecs.set<Camera>({ cameraNode, camera, false });
|
||||
PhysicsModule::configurePhysics();
|
||||
ecs.add<GameData>();
|
||||
ecs.add<Input>();
|
||||
ecs.observer<GameState>("Game_Start_Scen_Startup")
|
||||
@@ -212,9 +211,6 @@ void setupEditor(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
|
||||
Ogre::Camera *camera, Ogre::RenderWindow *window)
|
||||
{
|
||||
setup_minimal();
|
||||
Physics &ph = ECS::get().ensure<Physics>();
|
||||
ph.physics = new JoltPhysicsWrapper(scnMgr, cameraNode);
|
||||
ECS::modified<Physics>();
|
||||
ecs.component<RenderWindow>().add(flecs::Singleton);
|
||||
ecs.component<EditorSceneSwitch>().add(flecs::Singleton);
|
||||
ecs.import <CharacterModule>();
|
||||
@@ -267,7 +263,6 @@ void setupEditor(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
|
||||
#if 0
|
||||
ecs.set<EditorSceneSwitch>({ 0 });
|
||||
#endif
|
||||
PhysicsModule::configurePhysics();
|
||||
ecs.add<GameData>();
|
||||
ecs.add<Input>();
|
||||
ecs.add<WaterSurface>();
|
||||
|
||||
@@ -625,16 +625,15 @@ void PhysicsModule::setDebugDraw(bool enable)
|
||||
JoltPhysicsWrapper::getSingleton().setDebugDraw(enable);
|
||||
}
|
||||
|
||||
void PhysicsModule::configurePhysics()
|
||||
{
|
||||
}
|
||||
bool WaterBody::isInWater(const JPH::BodyID &id) const
|
||||
{
|
||||
#if 0
|
||||
flecs::entity e =
|
||||
ECS::get().query_builder<const JPH::BodyID>().build().find(
|
||||
[&](const JPH::BodyID &bodyid) {
|
||||
return bodyid == id;
|
||||
});
|
||||
#endif
|
||||
return inWater.find(id) != inWater.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _PHYSICS_MODULE_H_
|
||||
#define _PHYSICS_MODULE_H_
|
||||
#include <flecs.h>
|
||||
#include <Ogre.h>
|
||||
class JoltPhysicsWrapper;
|
||||
namespace JPH
|
||||
{
|
||||
@@ -61,7 +62,6 @@ struct PhysicsModule {
|
||||
const Ogre::Vector3 &endPos,
|
||||
Ogre::Vector3 &position, JPH::BodyID &id);
|
||||
static void setDebugDraw(bool enable);
|
||||
static void configurePhysics();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user