diff --git a/src/include/Application.h b/src/include/Application.h index 526814e..7c1799c 100644 --- a/src/include/Application.h +++ b/src/include/Application.h @@ -29,8 +29,6 @@ class Application { // : public GApp { void clearInstances(); void navigateToolbox(std::string); 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 run(); void QuitApp(); diff --git a/src/include/DataModelV3/Instance.h b/src/include/DataModelV3/Instance.h index 890a88b..edc5ee5 100644 --- a/src/include/DataModelV3/Instance.h +++ b/src/include/DataModelV3/Instance.h @@ -22,7 +22,10 @@ namespace B3D virtual void renderName(RenderDevice*); virtual void update(); virtual void setParent(Instance*); + + //TODO implement virtual Instance* clone() const { return new Instance(*this); } + virtual void reflectionNotify(ReflectionProperty* property); //Functions std::vector children; // All children. diff --git a/src/include/DataModelV3/PartInstance.h b/src/include/DataModelV3/PartInstance.h index 3718cf0..29923d1 100644 --- a/src/include/DataModelV3/PartInstance.h +++ b/src/include/DataModelV3/PartInstance.h @@ -62,7 +62,8 @@ namespace B3D void setShape(Enum::Shape::Value shape); void setChanged(); void setSurface(int face, Enum::SurfaceType::Value surface); - void setAnchored(bool anchored); + void setAnchored(bool anchored); + void reflectionNotify(ReflectionProperty* property); bool isAnchored(); float getMass(); bool isDragging(); diff --git a/src/include/Reflection/ReflectionDataTable.h b/src/include/Reflection/ReflectionDataTable.h index 7e7afaf..2277591 100644 --- a/src/include/Reflection/ReflectionDataTable.h +++ b/src/include/Reflection/ReflectionDataTable.h @@ -17,6 +17,7 @@ namespace B3D{ std::string ReflectionDataTable::getClassName(void); void mapProperty(std::string key, ReflectionProperty* prop); + void notify(ReflectionProperty* prop); private: //Perhaps not stored here? std::string className; diff --git a/src/include/Reflection/ReflectionProperty.h b/src/include/Reflection/ReflectionProperty.h index 9204526..6699efa 100644 --- a/src/include/Reflection/ReflectionProperty.h +++ b/src/include/Reflection/ReflectionProperty.h @@ -26,6 +26,7 @@ namespace B3D{ T* getValuePtr(); void setValue(T); + void setValueNotify(T); void dispose(); diff --git a/src/include/Reflection/ReflectionProperty_impl.h b/src/include/Reflection/ReflectionProperty_impl.h index aa030ba..095bfa0 100644 --- a/src/include/Reflection/ReflectionProperty_impl.h +++ b/src/include/Reflection/ReflectionProperty_impl.h @@ -46,7 +46,8 @@ void ReflectionProperty::dispose() //value = NULL; if(extData) { - delete extData; + //TODO why??? + //delete extData; extData = NULL; } } @@ -72,4 +73,10 @@ T* ReflectionProperty::getValuePtr() template void ReflectionProperty::setValue(T value){ value=T(value); +} + +template +void ReflectionProperty::setValueNotify(T value){ + value=T(value); + containerTable->notify((ReflectionProperty*)this); } \ No newline at end of file diff --git a/src/source/DataModelV3/DataModelInstance.cpp b/src/source/DataModelV3/DataModelInstance.cpp index cc60b23..19d8e5b 100644 --- a/src/source/DataModelV3/DataModelInstance.cpp +++ b/src/source/DataModelV3/DataModelInstance.cpp @@ -1,4 +1,6 @@ #include "DataModelV3/DataModelInstance.h" +//TODO should this be here? +#include "DataModelV3/Gui/ToggleImageButtonInstance.h" using namespace B3D; DataModelInstance::DataModelInstance(void) : Instance("DataModel") @@ -34,8 +36,6 @@ DataModelInstance::DataModelInstance(void) : Instance("DataModel") resetEngine(); } -//TODO implement - void DataModelInstance::resetEngine() { if(xplicitNgine != NULL) @@ -77,8 +77,7 @@ DataModelInstance::~DataModelInstance(void) void DataModelInstance::clearLevel() { running = false; - //TODO implement - /*Instance * goButton = this->getGuiRoot()->findFirstChild("go"); + Instance * goButton = this->getGuiRoot()->findFirstChild("go"); if(goButton != NULL){ if(ToggleImageButtonInstance* goButtonReal = dynamic_cast(goButton)) { @@ -87,7 +86,7 @@ void DataModelInstance::clearLevel() } selectionService->clearSelection(); selectionService->addSelected(this); - workspace->clearChildren();*/ + workspace->clearChildren(); } //TODO move elsewhere @@ -305,7 +304,6 @@ WorkspaceInstance* DataModelInstance::getWorkspace() return workspace; } -//TODO implement GuiRootInstance* DataModelInstance::getGuiRoot() { return guiRoot; @@ -333,7 +331,6 @@ SoundService* DataModelInstance::getSoundService() return soundService; } -//TODO implement LightingInstance* DataModelInstance::getLighting() { return lightingInstance; diff --git a/src/source/DataModelV3/Gui/BaseButtonInstance.cpp b/src/source/DataModelV3/Gui/BaseButtonInstance.cpp index f0d7cc9..ed969d9 100644 --- a/src/source/DataModelV3/Gui/BaseButtonInstance.cpp +++ b/src/source/DataModelV3/Gui/BaseButtonInstance.cpp @@ -10,7 +10,7 @@ void BaseButtonInstance::render(RenderDevice* rd) { //TODO make mouse a member of datamodel //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); } diff --git a/src/source/DataModelV3/Instance.cpp b/src/source/DataModelV3/Instance.cpp index cacf117..7a275b7 100644 --- a/src/source/DataModelV3/Instance.cpp +++ b/src/source/DataModelV3/Instance.cpp @@ -21,6 +21,7 @@ Instance::Instance(void) canDelete = true; } + Instance::~Instance(void) { for(size_t i = 0; i < children.size(); i++) @@ -36,6 +37,10 @@ Instance::Instance(const Instance &oinst) //CLONE WITH REFLECTION!!! } + +void Instance::reflectionNotify(ReflectionProperty * property){ +} + //Perhaps should be separated void Instance::render(RenderDevice* rd) { diff --git a/src/source/DataModelV3/LightingInstance.cpp b/src/source/DataModelV3/LightingInstance.cpp index bf58a9e..862f512 100644 --- a/src/source/DataModelV3/LightingInstance.cpp +++ b/src/source/DataModelV3/LightingInstance.cpp @@ -85,8 +85,7 @@ void LightingInstance::update(RenderDevice* rd) rd->setObjectToWorldMatrix(forDraw); rd->afterPrimitive(); - // TODO implement - //parentDataModel->getSelectionService()->render(rd); + parentDataModel->getSelectionService()->render(rd); // TODO Mouse and tool will be handled by datamodel //g_usableApp->tool->render(rd, g_usableApp->mouse); diff --git a/src/source/DataModelV3/PartInstance.cpp b/src/source/DataModelV3/PartInstance.cpp index 0e48f06..a30aa50 100644 --- a/src/source/DataModelV3/PartInstance.cpp +++ b/src/source/DataModelV3/PartInstance.cpp @@ -62,8 +62,7 @@ void PartInstance::setDragging(bool value) if (dragging != value && getParentDataModel() != NULL) { 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) { - //TODO implement engine - //getParentDataModel()->getEngine()->deleteBody(this); + getParentDataModel()->getEngine()->deleteBody(this); } Instance * cparent = getParent(); - //TODO implement workspace - /*while(cparent != NULL) + while(cparent != NULL) { if(WorkspaceInstance* workspace = dynamic_cast(cparent)) { workspace->partObjects.erase(std::remove(workspace->partObjects.begin(), workspace->partObjects.end(), this), workspace->partObjects.end()); } cparent = cparent->getParent(); - }*/ + } Instance::setParent(prnt); cparent = getParent(); - //TODO implement workspace - /* + while(cparent != NULL) { if(WorkspaceInstance* workspace = dynamic_cast(cparent)) @@ -214,8 +210,7 @@ void PartInstance::setParent(Instance* prnt) break; } cparent = cparent->getParent(); - }*/ - + } } void PartInstance::setSize(Vector3 newSize) @@ -305,7 +300,7 @@ bool PartInstance::isAnchored() CoordinateFrame PartInstance::getCFrame() { - return cFrame.value.rotation; + return cFrame.value; } void PartInstance::setCFrame(CoordinateFrame coordinateFrame) { @@ -338,6 +333,12 @@ bool PartInstance::collides(PartInstance * part) } } + +void PartInstance::reflectionNotify(ReflectionProperty* property){ + //TODO actually implement correctly + changed = true; +} + 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)); @@ -422,11 +423,9 @@ void PartInstance::onTouch() break; } - //TODO implement SoundService - /* SoundService* sndService = getParentDataModel()->getSoundService(); - switch(OnTouchSound) + switch(OnTouchSound.getValue()) { case Enum::Sound::NoSound: break; @@ -469,5 +468,5 @@ void PartInstance::onTouch() case Enum::Sound::StepOn: sndService->playSound(sndService->findFirstChild("StepOn")); break; - }*/ + } } diff --git a/src/source/Reflection/ReflectionDataTable.cpp b/src/source/Reflection/ReflectionDataTable.cpp index 37c8ee6..d9d5864 100644 --- a/src/source/Reflection/ReflectionDataTable.cpp +++ b/src/source/Reflection/ReflectionDataTable.cpp @@ -1,4 +1,5 @@ #include "Reflection/ReflectionDataTable.h" +#include "DataModelV3/Instance.h" using namespace B3D::Reflection; @@ -26,6 +27,11 @@ std::string ReflectionDataTable::getClassName(void) return className; } +void ReflectionDataTable::notify(ReflectionProperty* prop) +{ + parentInstance->reflectionNotify(prop); +} + void ReflectionDataTable::mapProperty(std::string key, ReflectionProperty* prop) { if(propertyTable.find(key) != propertyTable.end()) diff --git a/src/source/Tool/SurfaceTool.cpp b/src/source/Tool/SurfaceTool.cpp index 923cf13..eddffd1 100644 --- a/src/source/Tool/SurfaceTool.cpp +++ b/src/source/Tool/SurfaceTool.cpp @@ -37,10 +37,10 @@ std::vector getSurfaces(PartInstance * part) void SurfaceTool::onButton1MouseDown(Mouse mouse) { - AudioPlayer::playSound(dingSound); PartInstance * target = mouse.getTarget(); if(target != NULL) { + AudioPlayer::playSound(dingSound); G3D::Ray ray = mouse.getLastRay(); std::vector surfacesHit = getSurfaces(target); int closest;