Entities can now be created dynamically

This commit is contained in:
grayson committed 2021-10-31 23:25:08 -05:00
1 parent aa58238162
commit 43c3d3930f
7 files changed
+15 -18

No files matched your search

Binary file not shown.
+6 -8
View File
@@ -10,7 +10,7 @@
namespace nf {
Entity::Entity() :
m_constructed(false),
m_createdAtLoad(false),
m_member(false),
m_type(Type::STATIC),
m_model(nullptr),
m_position(0.0),
@@ -18,9 +18,8 @@ namespace nf {
m_scale(1.0),
m_update(false)
{
if (Application::getApp() && Application::getApp()->getCurrentState())
if (Application::getApp()->getCurrentState()->isLoading())
m_createdAtLoad = true;
if (!Application::getApp() || !Application::getApp()->getCurrentState())
m_member = true;
}
void Entity::create(Asset* modelAsset, Type type) {
@@ -46,11 +45,10 @@ namespace nf {
if (type != Type::DETAIL)
Application::getApp()->getPhysicsEngine()->addActor(this);
if (!Application::getApp()->getCurrentState()->isRunning())
if (m_createdAtLoad)
Application::getApp()->getCurrentState()->m_entsToDelete.push_back(this);
else
if (m_member)
Application::getApp()->getCurrentState()->m_nfObjects.push_back(this);
else
Application::getApp()->getCurrentState()->m_entsToDelete.push_back(this);
}
bool Entity::isConstructed() {
-2
View File
@@ -19,8 +19,6 @@ namespace nf {
Error("Model exceedes 32 texture limit!");
std::string obj = model->data;
size_t startMtlPos = obj.find("newmtl");
if (startMtlPos == std::string::npos)
Error("No materials found in model!");
std::string mtl = obj.substr(startMtlPos);
struct TempMaterial {
std::vector<float> outVB;
+1 -1
View File
@@ -49,7 +49,7 @@ namespace nf {
~Entity();
private:
bool m_constructed;
bool m_createdAtLoad;
bool m_member;
Type m_type;
Model* m_model;