updated TSE, and fixed some small bugs

This commit is contained in:
2026-01-25 10:55:32 +01:00
parent 8ece8ca96f
commit edf079caf8
11 changed files with 25 additions and 24 deletions

View File

@@ -36,7 +36,6 @@ GravityHolder::GravityHolder(float gravityWell)
GravityHolder::~GravityHolder() GravityHolder::~GravityHolder()
{ {
Transformable::HardDelete(planetMapRing, false);
delete mat; delete mat;
delete mesh; delete mesh;
} }

View File

@@ -14,7 +14,8 @@ PlanetRotater::PlanetRotater(float distance)
PlanetRotater::~PlanetRotater() PlanetRotater::~PlanetRotater()
{ {
Transformable::HardDelete(planetMapRing, false); planetMapRing->SetParent(nullptr);
Transformable::HardDelete(planetMapRing, true);
delete mat; delete mat;
delete mesh; delete mesh;
} }

View File

@@ -2,6 +2,7 @@
#include "Rendering/PlanetShader.hpp" #include "Rendering/PlanetShader.hpp"
#include "utils/Time.hpp" #include "utils/Time.hpp"
#include "BehaviourScripts/Camera.hpp" #include "BehaviourScripts/Camera.hpp"
#include "Debug.hpp"
SpaceController::SpaceController() SpaceController::SpaceController()
{ {

View File

@@ -2,7 +2,7 @@
Transformable *Asteroid::LoadSpace() Transformable *Asteroid::LoadSpace()
{ {
root = new Transformable(name); root = new Transformable(name, id);
Transformable* planet = create(); Transformable* planet = create();

View File

@@ -7,7 +7,7 @@
Transformable *Galaxy::LoadSpace() Transformable *Galaxy::LoadSpace()
{ {
root = new Transformable(name); root = new Transformable(name, id);
for (auto &&system : systems) for (auto &&system : systems)
{ {
@@ -22,8 +22,6 @@ Transformable *Galaxy::LoadSpace()
// position; // position;
} }
root->id = id;
float grvityWell = GetMaxDistObj(); float grvityWell = GetMaxDistObj();
GravityHolder* holder = new GravityHolder(grvityWell + 4.0f); GravityHolder* holder = new GravityHolder(grvityWell + 4.0f);

View File

@@ -4,7 +4,7 @@
Transformable *Moon::LoadSpace() Transformable *Moon::LoadSpace()
{ {
root = new Transformable(name); root = new Transformable(name, id);
Transformable* planet = create(); Transformable* planet = create();
@@ -148,7 +148,7 @@ void Moon::DeleteResources()
delete planetMesh; delete planetMesh;
delete landMat; delete landMat;
delete planetMat; delete planetMat;
Transformable::HardDelete(planetLand, true); // Transformable::HardDelete(planetLand, true);
planetBase->SetParent(nullptr); planetBase->SetParent(nullptr);
Transformable::HardDelete(planetBase, false); Transformable::HardDelete(planetBase, false);

View File

@@ -4,10 +4,11 @@
#include "Utilities/Random.hpp" #include "Utilities/Random.hpp"
#include "BehaviourScripts/GravityHolder.hpp" #include "BehaviourScripts/GravityHolder.hpp"
#include "BehaviourScripts/SpaceController.hpp" #include "BehaviourScripts/SpaceController.hpp"
#include "Debug.hpp"
Transformable *Planet::LoadSpace() Transformable *Planet::LoadSpace()
{ {
root = new Transformable(name); root = new Transformable(name, id);
Transformable* planet = create(); Transformable* planet = create();
@@ -23,17 +24,17 @@ Transformable *Planet::LoadSpace()
Vector2 pos = rotateKeepDistance(Vector2::zero, {0, moon->distanceToPlanet}, GetRandomFloat(0, 360), moon->distanceToPlanet); Vector2 pos = rotateKeepDistance(Vector2::zero, {0, moon->distanceToPlanet}, GetRandomFloat(0, 360), moon->distanceToPlanet);
moonObj->position = {pos.x, pos.y, -1}; moonObj->position = {pos.x, pos.y, -1};
} }
root->id = id;
return root; return root;
} }
void Planet::UnloadSpace() void Planet::UnloadSpace()
{ {
TSE_LOG("Obj count pre unload: " + std::to_string(Transformable::GetTansformableCount()));
DeleteResources(); DeleteResources();
root->SetParent(nullptr); root->SetParent(nullptr);
Transformable::HardDelete(root, true); Transformable::HardDelete(root, false);
TSE_LOG("Obj count post unload: " + std::to_string(Transformable::GetTansformableCount()));
} }
Transformable *Planet::create() Transformable *Planet::create()
@@ -213,8 +214,8 @@ void Planet::DeleteResources()
delete cloudMat; delete cloudMat;
delete landMat; delete landMat;
delete planetMat; delete planetMat;
Transformable::HardDelete(planetClouds, true); // Transformable::HardDelete(planetClouds, true);
Transformable::HardDelete(planetLand, true); // Transformable::HardDelete(planetLand, true);
planetBase->SetParent(nullptr); planetBase->SetParent(nullptr);
Transformable::HardDelete(planetBase, false); Transformable::HardDelete(planetBase, false);

View File

@@ -4,6 +4,7 @@
#include "Utilities/Random.hpp" #include "Utilities/Random.hpp"
#include "BehaviourScripts/GravityHolder.hpp" #include "BehaviourScripts/GravityHolder.hpp"
#include "BehaviourScripts/SpaceController.hpp" #include "BehaviourScripts/SpaceController.hpp"
#include "Debug.hpp"
void PlanetarySystem::DeleteResources() void PlanetarySystem::DeleteResources()
{ {
@@ -19,7 +20,8 @@ void PlanetarySystem::DeleteResources()
Transformable *PlanetarySystem::LoadSpace() Transformable *PlanetarySystem::LoadSpace()
{ {
root = new Transformable(name); if(name == "") name = "root";
root = new Transformable(name, id);
if(stars.size() == 1) if(stars.size() == 1)
{ {
@@ -38,8 +40,6 @@ Transformable *PlanetarySystem::LoadSpace()
planetObj->position = {pos.x, pos.y, -1}; planetObj->position = {pos.x, pos.y, -1};
} }
root->id = id;
float grvityWell = GetMaxPlanetDistance(); float grvityWell = GetMaxPlanetDistance();
GravityHolder* holder = new GravityHolder(grvityWell + 4.0f); GravityHolder* holder = new GravityHolder(grvityWell + 4.0f);
@@ -56,7 +56,8 @@ void PlanetarySystem::UnloadSpace()
{ {
DeleteResources(); DeleteResources();
root->SetParent(nullptr); root->SetParent(nullptr);
Transformable::HardDelete(root, true); Transformable::HardDelete(root, false);
} }
PlanetarySystem *PlanetarySystem::Load(nlohmann::json json) PlanetarySystem *PlanetarySystem::Load(nlohmann::json json)

View File

@@ -151,8 +151,8 @@ void Star::DeleteResources()
delete cloudMat; delete cloudMat;
delete landMat; delete landMat;
delete planetMat; delete planetMat;
Transformable::HardDelete(planetClouds, true); // Transformable::HardDelete(planetClouds, true);
Transformable::HardDelete(planetLand, true); // Transformable::HardDelete(planetLand, true);
planetBase->SetParent(nullptr); planetBase->SetParent(nullptr);
Transformable::HardDelete(planetBase, false); Transformable::HardDelete(planetBase, false);

View File

@@ -56,7 +56,7 @@ void SetupWindow()
TextureHandler::LoadTextures(); TextureHandler::LoadTextures();
currentScene = new Scene(); currentScene = new Scene();
Transformable* trans = new Transformable(); Transformable* trans = new Transformable("Space Controller");
planeteryLayer = new Layer("PlanetsAndStuff"); planeteryLayer = new Layer("PlanetsAndStuff");
currentScene->AddLayer(planeteryLayer); currentScene->AddLayer(planeteryLayer);
planeteryLayer->AddTransformable(trans); planeteryLayer->AddTransformable(trans);
@@ -66,7 +66,7 @@ void SetupWindow()
SpaceController* controller = (SpaceController*)trans->AddBehaviourScript(new SpaceController(cc)); SpaceController* controller = (SpaceController*)trans->AddBehaviourScript(new SpaceController(cc));
lc = GalaxyGenerator::GenerateCluster(69); lc = GalaxyGenerator::GenerateCluster(69);
controller->LoadSpace(lc->galaxies[0]->systems[96]); controller->LoadSpace(lc->galaxies[0]->systems[96]->planets[0]);
#ifdef USE_EDITOR #ifdef USE_EDITOR
currentScene->AddLayer(&editor->editorLayer); currentScene->AddLayer(&editor->editorLayer);

2
TSE

Submodule TSE updated: 11e8d343af...bf4189bba0