Fixed FGD saving, Scene building

This commit is contained in:
Antoine Pilote
2021-07-02 02:07:32 -04:00
parent 14190508cf
commit e5306bfed4
13 changed files with 391 additions and 158 deletions

View File

@@ -2,11 +2,40 @@
"Entities": [
{
"NameComponent": {
"ID": -1598095916,
"Name": "Model"
"ID": 130924321,
"Name": "testing"
},
"ParentComponent": {
"HasParent": false
"HasParent": true,
"ParentID": 130921466
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Scale": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": 1.125,
"y": -2.375,
"z": -6.375
},
"Type": "TransformComponent"
}
},
{
"NameComponent": {
"ID": 130921466,
"Name": "Brush 2"
},
"ParentComponent": {
"HasParent": true,
"ParentID": 237443808
},
"TransformComponent": {
"Rotation": {
@@ -28,14 +57,134 @@
}
},
{
"CharacterControllerComponent": {
"Height": 1.2000000476837158,
"Mass": 2500.0,
"Radius": 0.20000000298023224
"NameComponent": {
"ID": 130912441,
"Name": "TestTrigger"
},
"ParentComponent": {
"HasParent": true,
"ParentID": 130909903
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Scale": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": -0.25,
"y": -1.25,
"z": 0.875
},
"Type": "TransformComponent"
},
"WrenScriptComponent": {
"Class": "TriggerScript",
"Script": "Scripts/Trigger.wren"
}
},
{
"NameComponent": {
"ID": 130909903,
"Name": "Brush 1"
},
"ParentComponent": {
"HasParent": true,
"ParentID": 237443808
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Scale": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Type": "TransformComponent"
}
},
{
"NameComponent": {
"ID": 126715946,
"Name": ""
},
"ParentComponent": {
"HasParent": true,
"ParentID": 126713557
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Scale": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": 0.75,
"y": -2.875,
"z": -1.0
},
"Type": "TransformComponent"
}
},
{
"NameComponent": {
"ID": 126713557,
"Name": "Brush 0"
},
"ParentComponent": {
"HasParent": true,
"ParentID": 237443808
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Scale": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Type": "TransformComponent"
}
},
{
"CameraComponent": {
"CameraInstance": {
"AspectRatio": 1.9246861934661865,
"Exposure": 1.0,
"Fov": 88.0,
"Speed": 1.0,
"m_Type": 1
}
},
"NameComponent": {
"ID": 237171289,
"Name": "Player"
"ID": 237481018,
"Name": "Camera"
},
"ParentComponent": {
"HasParent": false
@@ -52,15 +201,46 @@
"z": 1.0
},
"Translation": {
"x": 2.5405828952789307,
"y": 0.0,
"z": 0.0
"x": 6.100314617156982,
"y": -49.37096405029297,
"z": -5.69704008102417
},
"Type": "TransformComponent"
},
"WrenScriptComponent": {
"Class": "PlayerScript",
"Script": "Scripts/Player.wren"
"Class": "CamScript",
"Script": "Scripts/Cam.wren"
}
},
{
"NameComponent": {
"ID": 237443808,
"Name": "Trenchbroom map"
},
"ParentComponent": {
"HasParent": false
},
"QuakeMapComponent": {
"HasCollisions": true,
"Path": "Maps/afgd.map"
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
"y": -0.0,
"z": 0.0
},
"Scale": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Type": "TransformComponent"
}
},
{
@@ -112,17 +292,18 @@
}
},
{
"CharacterControllerComponent": {
"Height": 1.2000000476837158,
"Mass": 2500.0,
"Radius": 0.20000000298023224
},
"NameComponent": {
"ID": 237443808,
"Name": "Trenchbroom map"
"ID": 237171289,
"Name": "Player"
},
"ParentComponent": {
"HasParent": false
},
"QuakeMapComponent": {
"HasCollisions": true,
"Path": "Maps/debug.map"
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
@@ -134,6 +315,37 @@
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": 6.100314617156982,
"y": 0.0,
"z": -5.69704008102417
},
"Type": "TransformComponent"
},
"WrenScriptComponent": {
"Class": "PlayerScript",
"Script": "Scripts/Player.wren"
}
},
{
"NameComponent": {
"ID": -1598095916,
"Name": "Model"
},
"ParentComponent": {
"HasParent": false
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Scale": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": 0.0,
"y": 0.0,
@@ -141,46 +353,6 @@
},
"Type": "TransformComponent"
}
},
{
"CameraComponent": {
"CameraInstance": {
"AspectRatio": 1.774647831916809,
"Exposure": 1.0,
"Fov": 88.0,
"Speed": 1.0,
"m_Type": 1
}
},
"NameComponent": {
"ID": 237481018,
"Name": "Camera"
},
"ParentComponent": {
"HasParent": false
},
"TransformComponent": {
"Rotation": {
"x": 0.0,
"y": -0.0,
"z": 0.0
},
"Scale": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"Translation": {
"x": -25.119064331054688,
"y": 19.491336822509766,
"z": 4.5285515785217285
},
"Type": "TransformComponent"
},
"WrenScriptComponent": {
"Class": "CamScript",
"Script": "Scripts/Cam.wren"
}
}
],
"Name": "",

View File

@@ -18,6 +18,7 @@ class TriggerScript is ScriptableEntity {
fixedUpdate(ts) {
var trigger = this.GetComponent("Trigger")
Engine.Log("Hello")
if(trigger.GetOverlappingBodyCount() > 0) {
var bodies = trigger.GetOverlappingBodies()
var brush = this.GetComponent("Brush")
@@ -31,14 +32,8 @@ class TriggerScript is ScriptableEntity {
for(t in brush.GetTargets()) {
var transform = t.GetComponent("Transform")
var pos = transform.GetTranslation()
var target = t.GetComponent("Brush")
var pos2 = target.GetTargets()[0].GetComponent("Transform")
var targetPos = pos2.GetTranslation()
if(pos.y < targetPos.y) {
pos.y = pos.y + 3.0 * ts
}
Engine.Log("Hello")
pos.x = pos.x + 1.0 * ts
transform.SetTranslation(pos)
}

View File

@@ -1,6 +1 @@
{
"DefaultScene":"Scenes/test.scene",
"Description":"",
"Name":"DemoProject",
"EntityDefinition": "lalala.json"
}
{"DefaultScene":"Scenes/test.scene","Description":"","EntityDefinition":"lalala.json","Name":"DemoProject","TrenchbroomPath":"F:\\TrenchBroom\\TrenchBroom.exe/../"}

View File

@@ -317,8 +317,9 @@ void EditorInterface::DrawSceneTree()
QueueDeletion = Entity{ (entt::entity)0, scene.get() };
ImGui::TreePop();
}
ImGui::End();
}
ImGui::End();
}
@@ -636,7 +637,6 @@ void EditorInterface::DrawEntityPropreties()
if (ImGui::Button("Build Geometry"))
{
QuakeMapBuilder mapBuilder;
mapBuilder.BuildQuakeMap(m_SelectedEntity);
}
ImGui::Separator();

View File

@@ -21,7 +21,6 @@ void ProjectInterface::DrawProjectSettings()
void ProjectInterface::DrawCreatePointEntity()
{
char buffer[256];
memset(buffer, 0, sizeof(buffer));
std::strncpy(buffer, Engine::GetProject()->Name.c_str(), sizeof(buffer));
@@ -45,9 +44,8 @@ void ProjectInterface::DrawEntitySettings()
ImGui::Text("Trenchbroom path:");
ImGui::SameLine();
ImGuiTextSTD("", m_CurrentProject->TrenchbroomPath);
ImGui::SameLine();
if (ImGui::Button("Browse"))
{
std::string path = FileDialog::OpenFile("*.exe");
@@ -162,6 +160,7 @@ void ProjectInterface::DrawEntitySettings()
ImGui::EndChild();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Brush entities"))
{
ImVec2 avail = ImGui::GetContentRegionAvail();
@@ -187,9 +186,9 @@ void ProjectInterface::DrawEntitySettings()
ImGui::Checkbox(std::string("Visible##" + std::to_string(i)).c_str(), &pE.Visible);
ImGui::SameLine();
ImGui::Checkbox(std::string("Solid" + std::to_string(i)).c_str(), &pE.Solid);
ImGui::Checkbox(std::string("Solid##" + std::to_string(i)).c_str(), &pE.Solid);
ImGui::SameLine();
ImGui::Checkbox(std::string("Trigger" + std::to_string(i)).c_str(), &pE.IsTrigger);
ImGui::Checkbox(std::string("Trigger##" + std::to_string(i)).c_str(), &pE.IsTrigger);
ImGui::TableNextColumn();
@@ -205,6 +204,7 @@ void ProjectInterface::DrawEntitySettings()
ImGui::EndDragDropTarget();
}
ImGuiTextSTD("Class##" + std::to_string(i), pE.Class);
ImGui::TableNextColumn();
i++;

View File

@@ -100,7 +100,8 @@ namespace Physics
// Skip the rigid body the ghost monitors
if (pManifold->getBody0() == m_Rigidbody)
continue;
btVector3 boost = pManifold->getBody0()->getInterpolationLinearVelocity();
m_manualVelocity += Vector3(boost.x(), boost.y(), boost.z());
for (int p = 0; p < pManifold->getNumContacts(); p++)
{
const btManifoldPoint& point = pManifold->getContactPoint(p);

View File

@@ -23,7 +23,7 @@ public:
bool Solid = false;
bool IsTrigger = false;
std::string Script = "";
std::string Class = "";
std::vector<ClassProperty> Properties;
FGDBrushEntity()
@@ -47,6 +47,7 @@ public:
SERIALIZE_VAL(Solid);
SERIALIZE_VAL(IsTrigger);
SERIALIZE_VAL(Script);
SERIALIZE_VAL(Class);
END_SERIALIZE();
}
@@ -59,6 +60,7 @@ public:
Solid = j["Solid"];
IsTrigger = j["IsTrigger"];
Script = j["Script"];
Class = j["Class"];
return true;
}

View File

@@ -31,25 +31,9 @@ FGDFile::FGDFile()
bool FGDFile::Save()
{
BEGIN_SERIALIZE();
int i = 0;
for (auto& c : this->BrushEntities)
{
j["BrushEntities"][i] = c.Serialize();
i++;
}
i = 0;
for (auto& c : this->PointEntities)
{
j["PointEntities"][i] = c.Serialize();
i++;
}
// Write to file.
FileSystem::BeginWriteFile(Path);
FileSystem::WriteLine(j.dump(4));
FileSystem::BeginWriteFile(FileSystem::Root + Path);
FileSystem::WriteLine(Serialize().dump(4));
FileSystem::EndWriteFile();
return true;

View File

@@ -4,6 +4,11 @@
#include <string>
#include <vector>
enum class EntityType
{
Brush, Point, Base, None
};
class FGDFile : ISerializable{
public:
std::string Path;
@@ -19,13 +24,25 @@ public:
bool Save();
bool SaveAs();
void AddClass(FGDClass fgdClass);
void AddClass(FGDClass fgdClass);
void RemoveClass(const std::string& name);
json Serialize() override
{
BEGIN_SERIALIZE();
int i = 0;
for (auto& c : this->BrushEntities)
{
j["BrushEntities"][i] = c.Serialize();
i++;
}
i = 0;
for (auto& c : this->PointEntities)
{
j["PointEntities"][i] = c.Serialize();
i++;
}
END_SERIALIZE();
}
@@ -41,7 +58,6 @@ public:
brushEntity.Deserialize(brush.dump());
BrushEntities.push_back(brushEntity);
}
}
if (j.contains("PointEntities"))
@@ -51,4 +67,30 @@ public:
return true;
}
FGDBrushEntity& GetBrushEntity(const std::string& name)
{
for (auto& b : BrushEntities)
{
if (b.Name == name)
return b;
}
}
EntityType GetTypeOfEntity(const std::string& className)
{
for (auto& b : BrushEntities)
{
if (b.Name == className)
return EntityType::Brush;
}
for (auto& p : PointEntities)
{
if (p.Name == className)
return EntityType::Point;
}
return EntityType::None;
}
};

View File

@@ -90,6 +90,7 @@ json Project::Serialize()
SERIALIZE_VAL(Description);
SERIALIZE_VAL_LBL("DefaultScene", DefaultScene->Path);
SERIALIZE_VAL_LBL("EntityDefinition", EntityDefinitionsFile->Path);
SERIALIZE_VAL(TrenchbroomPath);
END_SERIALIZE();
}
@@ -128,6 +129,11 @@ bool Project::Deserialize(const std::string& str)
EntityDefinitionsFile->Deserialize(content);
}
if (j.contains("TrenchbroomPath"))
{
this->TrenchbroomPath = j["TrenchbroomPath"];
}
DefaultScene->Path = scenePath;
Logger::Log("Successfully loaded scene: " + scenePath);

View File

@@ -178,7 +178,8 @@ void Scene::DrawShadows()
for (auto e : quakeView) {
auto [transform, model] = quakeView.get<TransformComponent, BSPBrushComponent>(e);
Renderer::m_ShadowmapShader->SetUniformMat4f("model", transform.GetTransform());
if (model.IsTransparent)
continue;
for (auto& e : model.Meshes) {
e->Draw(false);
}
@@ -255,7 +256,8 @@ void Scene::Draw()
auto quakeView = m_Registry.view<TransformComponent, BSPBrushComponent, ParentComponent>();
for (auto e : quakeView) {
auto [transform, model, parent] = quakeView.get<TransformComponent, BSPBrushComponent, ParentComponent>(e);
if (model.IsTransparent)
continue;
Renderer::m_Shader->SetUniformMat4f("u_View", cam->GetTransform());
Renderer::m_Shader->SetUniformMat4f("u_Projection", cam->GetPerspective());
Renderer::m_Shader->SetUniformMat4f("u_Model", transform.GetTransform());
@@ -268,6 +270,7 @@ void Scene::Draw()
Renderer::m_DebugShader->SetUniformMat4f("u_View", cam->GetTransform());
Renderer::m_DebugShader->SetUniformMat4f("u_Projection", cam->GetPerspective());
PhysicsManager::Get()->DrawDebug();
}
}

View File

@@ -7,6 +7,7 @@
#include <iostream>
#include <sstream>
#include "src/Core/FileSystem.h"
extern "C" {
#include "libmap/h/map_parser.h"
#include <libmap/h/geo_generator.h>
@@ -19,14 +20,17 @@ extern "C" {
#include <src/Scene/Components/LightComponent.h>
#include <src/Scene/Components/NameComponent.h>
#include <src/Scene/Components/TriggerZone.h>
#include <src/Resource/FGD/FGDClass.h>
#include <src/Scene/Components/WrenScriptComponent.h>
Ref<Material> DefaultMaterial;
std::vector<std::string> split(const std::string& s, char delim) {
std::vector<std::string> split(const std::string& s, char delim)
{
std::vector<std::string> result;
std::stringstream ss(s);
std::string item;
while (getline(ss, item, delim)) {
while (getline(ss, item, delim))
{
result.push_back(item);
}
@@ -102,7 +106,8 @@ void QuakeMapBuilder::CreateBrush(brush* brush, brush_geometry* brush_inst, Scen
parent.AddChild(brushEntity);
transformComponent.Translation = Vector3(brush->center.y * (1.0f / 64),
transformComponent.Translation = Vector3(
brush->center.y * (1.0f / 64),
brush->center.z * (1.0f / 64),
brush->center.x * (1.0f / 64));
@@ -113,13 +118,16 @@ void QuakeMapBuilder::CreateBrush(brush* brush, brush_geometry* brush_inst, Scen
{
face* face = &brush->faces[f];
texture_data* texture = &textures[face->texture_idx];
if (std::string(texture->name) == "__TB_empty") {
if (std::string(texture->name) == "__TB_empty")
{
texture->height = 1;
texture->width = 1;
}
else {
else
{
std::string path = "resources/Textures/" + std::string(texture->name) + ".png";
auto tex = TextureManager::Get()->GetTexture(path);
texture->height = tex->GetHeight();
texture->width = tex->GetWidth();
}
@@ -136,6 +144,7 @@ void QuakeMapBuilder::CreateBrush(brush* brush, brush_geometry* brush_inst, Scen
(vertex.vertex.z - brush->center.z) * (1.0f / 64),
(vertex.vertex.x - brush->center.x) * (1.0f / 64)
);
Vector2 vertexUV = Vector2(vertex_uv.u, 1.0 - vertex_uv.v);
Vector3 vertexNormal = Vector3(vertex.normal.y, vertex.normal.z, vertex.normal.x);
Vector3 vertexTangent = Vector3(vertex.tangent.y, vertex.tangent.z, vertex.tangent.x);
@@ -158,6 +167,7 @@ void QuakeMapBuilder::CreateBrush(brush* brush, brush_geometry* brush_inst, Scen
if (lastTextureID != face->texture_idx)
{
lastTexturePath = "resources/Textures/" + std::string(texture->name) + ".png";
if (std::string(texture->name) == "__TB_empty")
bsp.Meshes.push_back(CreateRef<Mesh>(vertices, indices, DefaultMaterial));
else
@@ -178,34 +188,62 @@ void QuakeMapBuilder::CreateBrush(brush* brush, brush_geometry* brush_inst, Scen
bsp.Meshes.push_back(CreateRef<Mesh>(vertices, indices, MaterialManager::Get()->GetMaterial(lastTexturePath)));
}
void QuakeMapBuilder::CreateFuncBrush(brush* brush, brush_geometry* brush_inst, Scene* scene, Entity& parent, std::string target, std::string targetname)
void QuakeMapBuilder::CreateFuncBrush(brush* brush, brush_geometry* brush_inst, Scene* scene, Entity& parent, std::string target, std::string targetname, FGDBrushEntity fgdBrush)
{
std::vector<Vertex> vertices;
std::vector<unsigned int> indices;
Entity brushEntity = scene->CreateEntity(targetname);
std::string name = fgdBrush.Name;
if (targetname != "")
name = targetname;
Entity brushEntity = scene->CreateEntity(name);
TransformComponent& transformComponent = brushEntity.GetComponent<TransformComponent>();
BSPBrushComponent& bsp = brushEntity.AddComponent<BSPBrushComponent>();
bsp.IsSolid = fgdBrush.Solid;
bsp.IsTransparent = !fgdBrush.Visible;
bsp.IsFunc = true;
bsp.IsTrigger = fgdBrush.IsTrigger;
if (fgdBrush.Script != "" && fgdBrush.Class != "")
{
auto& wrenScript = brushEntity.AddComponent<WrenScriptComponent>();
wrenScript.Script = fgdBrush.Script;
wrenScript.Class = fgdBrush.Class;
}
if (bsp.IsTrigger)
{
TriggerZone& trigger = brushEntity.AddComponent<TriggerZone>();
trigger.target = target;
}
bsp.target = target;
parent.AddChild(brushEntity);
transformComponent.Translation = Vector3(brush->center.y * (1.0f / 64),
transformComponent.Translation = Vector3(
brush->center.y * (1.0f / 64),
brush->center.z * (1.0f / 64),
brush->center.x * (1.0f / 64));
int index_offset = 0;
int lastTextureID = -1;
std::string lastTexturePath = "";
for (int f = 0; f < brush->face_count; ++f)
{
face* face = &brush->faces[f];
texture_data* texture = &textures[face->texture_idx];
if (std::string(texture->name) == "__TB_empty") {
if (std::string(texture->name) == "__TB_empty")
{
texture->height = 1;
texture->width = 1;
}
else {
else
{
std::string path = "resources/Textures/" + std::string(texture->name) + ".png";
auto tex = TextureManager::Get()->GetTexture(path);
texture->height = tex->GetHeight();
@@ -224,17 +262,21 @@ void QuakeMapBuilder::CreateFuncBrush(brush* brush, brush_geometry* brush_inst,
(vertex.vertex.z - brush->center.z) * (1.0f / 64),
(vertex.vertex.x - brush->center.x) * (1.0f / 64)
);
Vector2 vertexUV = Vector2(vertex_uv.u, 1.0 - vertex_uv.v);
Vector3 vertexNormal = Vector3(vertex.normal.y, vertex.normal.z, vertex.normal.x);
Vector3 vertexTangent = Vector3(vertex.tangent.y, vertex.tangent.z, vertex.tangent.x);
vertices.push_back(Vertex{
vertexPos,
vertexUV,
vertexNormal,
vertexTangent,
glm::vec3(0.0, 1.0, 0.0), 0.0f
});
vertices.push_back(Vertex
{
vertexPos,
vertexUV,
vertexNormal,
vertexTangent,
glm::vec3(0.0, 1.0, 0.0),
0.0f
}
);
}
for (int i = 0; i < (face_geo_inst->vertex_count - 2) * 3; ++i)
@@ -279,7 +321,8 @@ void QuakeMapBuilder::BuildQuakeMap(Entity& ent, bool Collisions)
// Copy queue, cant delete while iterating.
auto deletionQueue = currentParent.Children;
for (auto& e : deletionQueue) {
for (auto& e : deletionQueue)
{
m_Scene->DestroyEntity(e);
}
@@ -304,6 +347,8 @@ void QuakeMapBuilder::BuildQuakeMap(Entity& ent, bool Collisions)
std::string target = "";
std::string targetname = "";
FGDBrushEntity fgdBrush;
bool isEntity = false;
for (int i = 0; i < entity_inst->property_count; i++)
{
property* prop = &(entity_inst->properties)[i];
@@ -312,7 +357,7 @@ void QuakeMapBuilder::BuildQuakeMap(Entity& ent, bool Collisions)
if (key == "origin")
{
// Position
// Positon split with space.
std::vector<std::string> splits = split(value, ' ');
float x = std::stof(splits[1]) * (1.f / 64.f);
@@ -325,36 +370,23 @@ void QuakeMapBuilder::BuildQuakeMap(Entity& ent, bool Collisions)
if (key == "classname")
{
if (value == "light")
Ref<FGDFile> file = Engine::GetProject()->EntityDefinitionsFile;
EntityType type = file->GetTypeOfEntity(value);
if (type != EntityType::None)
{
newEntity.AddComponent<LightComponent>();
newEntity.GetComponent<NameComponent>().Name = "Light " + std::to_string(i);
}
else if (value == "trigger")
{
//newEntity.AddComponent<LightComponent>();
isTrigger = true;
newEntity.GetComponent<NameComponent>().Name = "Trigger " + std::to_string(i);
}
else if (value == "func_any")
{
isFunc = true;
newEntity.GetComponent<NameComponent>().Name = "func_any " + std::to_string(i);
}
else if (value == "position")
{
isPos = true;
if (type == EntityType::Brush)
{
fgdBrush = file->GetBrushEntity(value);
isEntity = true;
}
}
}
if (key == "targetname") {
if (isPos) {
newEntity.GetComponent<NameComponent>().Name = value;
isPos = false;
}
if (key == "targetname")
{
targetname = value;
}
if (key == "target") {
if (key == "target")
{
target = value;
}
}
@@ -362,16 +394,16 @@ void QuakeMapBuilder::BuildQuakeMap(Entity& ent, bool Collisions)
{
brush* brush_inst = &entity_inst->brushes[b];
brush_geometry* brush_geo_inst = &entity_geo_inst->brushes[b];
if (isTrigger) {
CreateTrigger(brush_inst, brush_geo_inst, m_Scene, newEntity, target, targetname);
if (isEntity)
{
CreateFuncBrush(brush_inst, brush_geo_inst, m_Scene, newEntity, target, targetname, fgdBrush);
}
else if (isFunc) {
CreateFuncBrush(brush_inst, brush_geo_inst, m_Scene, newEntity, target, targetname);
}
else {
else
{
CreateBrush(brush_inst, brush_geo_inst, m_Scene, newEntity, target, targetname);
}
}
isEntity = false;
}
}

View File

@@ -4,12 +4,13 @@ class Entity;
class Scene;
struct brush;
struct brush_geometry;
class FGDBrushEntity;
class QuakeMapBuilder
{
private:
void CreateTrigger(brush* brush, brush_geometry* brush_inst, Scene* scene, Entity& parent, std::string target, std::string targetname);
void CreateBrush(brush* brush, brush_geometry* brush_inst, Scene* scene, Entity& parent, std::string target, std::string targetname);
void CreateFuncBrush(brush* brush, brush_geometry* brush_inst, Scene* scene, Entity& parent, std::string target, std::string targetname);
void CreateFuncBrush(brush* brush, brush_geometry* brush_inst, Scene* scene, Entity& parent, std::string target, std::string targetname, FGDBrushEntity fgdBrush);
public:
QuakeMapBuilder(){}