Minor bugfix, added reflection notify

This commit is contained in:
Vulpovile
2023-11-09 00:36:59 -08:00
parent 11362f0f63
commit 39d91f3943
13 changed files with 48 additions and 31 deletions

View File

@@ -29,8 +29,6 @@ class Application { // : public GApp {
void clearInstances(); void clearInstances();
void navigateToolbox(std::string); void navigateToolbox(std::string);
PartInstance* makePart(); PartInstance* makePart();
void drawButtons(RenderDevice* rd);
void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c);
void deleteInstance(); void deleteInstance();
void run(); void run();
void QuitApp(); void QuitApp();

View File

@@ -22,7 +22,10 @@ namespace B3D
virtual void renderName(RenderDevice*); virtual void renderName(RenderDevice*);
virtual void update(); virtual void update();
virtual void setParent(Instance*); virtual void setParent(Instance*);
//TODO implement
virtual Instance* clone() const { return new Instance(*this); } virtual Instance* clone() const { return new Instance(*this); }
virtual void reflectionNotify(ReflectionProperty<void*>* property);
//Functions //Functions
std::vector<Instance*> children; // All children. std::vector<Instance*> children; // All children.

View File

@@ -62,7 +62,8 @@ namespace B3D
void setShape(Enum::Shape::Value shape); void setShape(Enum::Shape::Value shape);
void setChanged(); void setChanged();
void setSurface(int face, Enum::SurfaceType::Value surface); void setSurface(int face, Enum::SurfaceType::Value surface);
void setAnchored(bool anchored); void setAnchored(bool anchored);
void reflectionNotify(ReflectionProperty<void*>* property);
bool isAnchored(); bool isAnchored();
float getMass(); float getMass();
bool isDragging(); bool isDragging();

View File

@@ -17,6 +17,7 @@ namespace B3D{
std::string ReflectionDataTable::getClassName(void); std::string ReflectionDataTable::getClassName(void);
void mapProperty(std::string key, ReflectionProperty<void*>* prop); void mapProperty(std::string key, ReflectionProperty<void*>* prop);
void notify(ReflectionProperty<void*>* prop);
private: private:
//Perhaps not stored here? //Perhaps not stored here?
std::string className; std::string className;

View File

@@ -26,6 +26,7 @@ namespace B3D{
T* getValuePtr(); T* getValuePtr();
void setValue(T); void setValue(T);
void setValueNotify(T);
void dispose(); void dispose();

View File

@@ -46,7 +46,8 @@ void ReflectionProperty<T>::dispose()
//value = NULL; //value = NULL;
if(extData) if(extData)
{ {
delete extData; //TODO why???
//delete extData;
extData = NULL; extData = NULL;
} }
} }
@@ -72,4 +73,10 @@ T* ReflectionProperty<T>::getValuePtr()
template<class T> template<class T>
void ReflectionProperty<T>::setValue(T value){ void ReflectionProperty<T>::setValue(T value){
value=T(value); value=T(value);
}
template<class T>
void ReflectionProperty<T>::setValueNotify(T value){
value=T(value);
containerTable->notify((ReflectionProperty<void*>*)this);
} }

View File

@@ -1,4 +1,6 @@
#include "DataModelV3/DataModelInstance.h" #include "DataModelV3/DataModelInstance.h"
//TODO should this be here?
#include "DataModelV3/Gui/ToggleImageButtonInstance.h"
using namespace B3D; using namespace B3D;
DataModelInstance::DataModelInstance(void) : Instance("DataModel") DataModelInstance::DataModelInstance(void) : Instance("DataModel")
@@ -34,8 +36,6 @@ DataModelInstance::DataModelInstance(void) : Instance("DataModel")
resetEngine(); resetEngine();
} }
//TODO implement
void DataModelInstance::resetEngine() void DataModelInstance::resetEngine()
{ {
if(xplicitNgine != NULL) if(xplicitNgine != NULL)
@@ -77,8 +77,7 @@ DataModelInstance::~DataModelInstance(void)
void DataModelInstance::clearLevel() void DataModelInstance::clearLevel()
{ {
running = false; running = false;
//TODO implement Instance * goButton = this->getGuiRoot()->findFirstChild("go");
/*Instance * goButton = this->getGuiRoot()->findFirstChild("go");
if(goButton != NULL){ if(goButton != NULL){
if(ToggleImageButtonInstance* goButtonReal = dynamic_cast<ToggleImageButtonInstance*>(goButton)) if(ToggleImageButtonInstance* goButtonReal = dynamic_cast<ToggleImageButtonInstance*>(goButton))
{ {
@@ -87,7 +86,7 @@ void DataModelInstance::clearLevel()
} }
selectionService->clearSelection(); selectionService->clearSelection();
selectionService->addSelected(this); selectionService->addSelected(this);
workspace->clearChildren();*/ workspace->clearChildren();
} }
//TODO move elsewhere //TODO move elsewhere
@@ -305,7 +304,6 @@ WorkspaceInstance* DataModelInstance::getWorkspace()
return workspace; return workspace;
} }
//TODO implement
GuiRootInstance* DataModelInstance::getGuiRoot() GuiRootInstance* DataModelInstance::getGuiRoot()
{ {
return guiRoot; return guiRoot;
@@ -333,7 +331,6 @@ SoundService* DataModelInstance::getSoundService()
return soundService; return soundService;
} }
//TODO implement
LightingInstance* DataModelInstance::getLighting() LightingInstance* DataModelInstance::getLighting()
{ {
return lightingInstance; return lightingInstance;

View File

@@ -10,7 +10,7 @@ void BaseButtonInstance::render(RenderDevice* rd)
{ {
//TODO make mouse a member of datamodel //TODO make mouse a member of datamodel
//Vector2 pos = Vector2(g_usableApp->mouse.x,g_usableApp->mouse.y); //Vector2 pos = Vector2(g_usableApp->mouse.x,g_usableApp->mouse.y);
//drawObj(rd, pos, g_usableApp->mouse.isMouseDown()); drawObj(rd, Vector2(0, 0), false);//g_usableApp->mouse.isMouseDown());
Instance::render(rd); Instance::render(rd);
} }

View File

@@ -21,6 +21,7 @@ Instance::Instance(void)
canDelete = true; canDelete = true;
} }
Instance::~Instance(void) Instance::~Instance(void)
{ {
for(size_t i = 0; i < children.size(); i++) for(size_t i = 0; i < children.size(); i++)
@@ -36,6 +37,10 @@ Instance::Instance(const Instance &oinst)
//CLONE WITH REFLECTION!!! //CLONE WITH REFLECTION!!!
} }
void Instance::reflectionNotify(ReflectionProperty<void*> * property){
}
//Perhaps should be separated //Perhaps should be separated
void Instance::render(RenderDevice* rd) void Instance::render(RenderDevice* rd)
{ {

View File

@@ -85,8 +85,7 @@ void LightingInstance::update(RenderDevice* rd)
rd->setObjectToWorldMatrix(forDraw); rd->setObjectToWorldMatrix(forDraw);
rd->afterPrimitive(); rd->afterPrimitive();
// TODO implement parentDataModel->getSelectionService()->render(rd);
//parentDataModel->getSelectionService()->render(rd);
// TODO Mouse and tool will be handled by datamodel // TODO Mouse and tool will be handled by datamodel
//g_usableApp->tool->render(rd, g_usableApp->mouse); //g_usableApp->tool->render(rd, g_usableApp->mouse);

View File

@@ -62,8 +62,7 @@ void PartInstance::setDragging(bool value)
if (dragging != value && getParentDataModel() != NULL) if (dragging != value && getParentDataModel() != NULL)
{ {
dragging = value; dragging = value;
//TODO implement engine getParentDataModel()->getEngine()->resetBody(this);
//getParentDataModel()->getEngine()->resetBody(this);
} }
} }
@@ -189,23 +188,20 @@ void PartInstance::setParent(Instance* prnt)
{ {
if(this->physBody != NULL && getParentDataModel() != NULL) if(this->physBody != NULL && getParentDataModel() != NULL)
{ {
//TODO implement engine getParentDataModel()->getEngine()->deleteBody(this);
//getParentDataModel()->getEngine()->deleteBody(this);
} }
Instance * cparent = getParent(); Instance * cparent = getParent();
//TODO implement workspace while(cparent != NULL)
/*while(cparent != NULL)
{ {
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(cparent)) if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(cparent))
{ {
workspace->partObjects.erase(std::remove(workspace->partObjects.begin(), workspace->partObjects.end(), this), workspace->partObjects.end()); workspace->partObjects.erase(std::remove(workspace->partObjects.begin(), workspace->partObjects.end(), this), workspace->partObjects.end());
} }
cparent = cparent->getParent(); cparent = cparent->getParent();
}*/ }
Instance::setParent(prnt); Instance::setParent(prnt);
cparent = getParent(); cparent = getParent();
//TODO implement workspace
/*
while(cparent != NULL) while(cparent != NULL)
{ {
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(cparent)) if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(cparent))
@@ -214,8 +210,7 @@ void PartInstance::setParent(Instance* prnt)
break; break;
} }
cparent = cparent->getParent(); cparent = cparent->getParent();
}*/ }
} }
void PartInstance::setSize(Vector3 newSize) void PartInstance::setSize(Vector3 newSize)
@@ -305,7 +300,7 @@ bool PartInstance::isAnchored()
CoordinateFrame PartInstance::getCFrame() CoordinateFrame PartInstance::getCFrame()
{ {
return cFrame.value.rotation; return cFrame.value;
} }
void PartInstance::setCFrame(CoordinateFrame coordinateFrame) void PartInstance::setCFrame(CoordinateFrame coordinateFrame)
{ {
@@ -338,6 +333,12 @@ bool PartInstance::collides(PartInstance * part)
} }
} }
void PartInstance::reflectionNotify(ReflectionProperty<void*>* property){
//TODO actually implement correctly
changed = true;
}
Box PartInstance::getBox() Box PartInstance::getBox()
{ {
Box box = Box(Vector3(size.value.x/2, size.value.y/2, size.value.z/2) ,Vector3(-size.value.x/2,-size.value.y/2,-size.value.z/2)); Box box = Box(Vector3(size.value.x/2, size.value.y/2, size.value.z/2) ,Vector3(-size.value.x/2,-size.value.y/2,-size.value.z/2));
@@ -422,11 +423,9 @@ void PartInstance::onTouch()
break; break;
} }
//TODO implement SoundService
/*
SoundService* sndService = getParentDataModel()->getSoundService(); SoundService* sndService = getParentDataModel()->getSoundService();
switch(OnTouchSound) switch(OnTouchSound.getValue())
{ {
case Enum::Sound::NoSound: case Enum::Sound::NoSound:
break; break;
@@ -469,5 +468,5 @@ void PartInstance::onTouch()
case Enum::Sound::StepOn: case Enum::Sound::StepOn:
sndService->playSound(sndService->findFirstChild("StepOn")); sndService->playSound(sndService->findFirstChild("StepOn"));
break; break;
}*/ }
} }

View File

@@ -1,4 +1,5 @@
#include "Reflection/ReflectionDataTable.h" #include "Reflection/ReflectionDataTable.h"
#include "DataModelV3/Instance.h"
using namespace B3D::Reflection; using namespace B3D::Reflection;
@@ -26,6 +27,11 @@ std::string ReflectionDataTable::getClassName(void)
return className; return className;
} }
void ReflectionDataTable::notify(ReflectionProperty<void*>* prop)
{
parentInstance->reflectionNotify(prop);
}
void ReflectionDataTable::mapProperty(std::string key, ReflectionProperty<void*>* prop) void ReflectionDataTable::mapProperty(std::string key, ReflectionProperty<void*>* prop)
{ {
if(propertyTable.find(key) != propertyTable.end()) if(propertyTable.find(key) != propertyTable.end())

View File

@@ -37,10 +37,10 @@ std::vector<G3D::Box> getSurfaces(PartInstance * part)
void SurfaceTool::onButton1MouseDown(Mouse mouse) void SurfaceTool::onButton1MouseDown(Mouse mouse)
{ {
AudioPlayer::playSound(dingSound);
PartInstance * target = mouse.getTarget(); PartInstance * target = mouse.getTarget();
if(target != NULL) if(target != NULL)
{ {
AudioPlayer::playSound(dingSound);
G3D::Ray ray = mouse.getLastRay(); G3D::Ray ray = mouse.getLastRay();
std::vector<G3D::Box> surfacesHit = getSurfaces(target); std::vector<G3D::Box> surfacesHit = getSurfaces(target);
int closest; int closest;