diff --git a/Blocks3D VS2003.vcproj b/Blocks3D VS2003.vcproj index d80f152..acccc70 100644 --- a/Blocks3D VS2003.vcproj +++ b/Blocks3D VS2003.vcproj @@ -382,6 +382,9 @@ + + ::dispose() delete extData; extData = NULL; } +} + +template +T ReflectionProperty::getValueClone() +{ + return T(value); +} + +template +T ReflectionProperty::getValue() +{ + return *value; +} + +template +T* ReflectionProperty::getValuePtr() +{ + return value; +} + +template +void ReflectionProperty::setValue(T value){ + this=value; } \ No newline at end of file diff --git a/src/include/Reflection/ReflectionProperty_op_overload.h b/src/include/Reflection/ReflectionProperty_op_overload.h new file mode 100644 index 0000000..e4abe88 --- /dev/null +++ b/src/include/Reflection/ReflectionProperty_op_overload.h @@ -0,0 +1,175 @@ + //Operator Overloads + T operator()() + { + return *value; + } + //Assignment Operators + T operator=(T nVal) + { + (*value) = nVal; + return *value; + } + + T operator+=(T nVal) + { + (*value) += nVal; + return *value; + } + + T operator-=(T nVal) + { + (*value)-= nVal; + return *value; + } + + T operator/=(T nVal) + { + (*value) /= nVal; + return *value; + } + + T operator*=(T nVal) + { + (*value) *= nVal; + return *value; + } + + T operator%=(T nVal) + { + (*value) %= nVal; + return *value; + } + + T operator^=(T nVal) + { + (*value) ^= nVal; + return *value; + } + + T operator&=(T nVal) + { + (*value) &= nVal; + return *value; + } + + T operator|=(T nVal) + { + (*value) |= nVal; + return *value; + } + + T operator>>=(T nVal) + { + (*value) >>= nVal; + return *value; + } + + T operator<<=(T nVal) + { + (*value) <<= nVal; + return *value; + } + + + //Mathematical Operations + T operator+(T nVal) + { + return (*value) + nVal; + } + + T operator-(T nVal) + { + return (*value) - nVal; + } + + T operator*(T nVal) + { + return (*value) - nVal; + } + + T operator/(T nVal) + { + return (*value) / nVal; + } + + T operator%(T nVal) + { + return (*value) % nVal; + } + + //Boolean operations + bool operator==(T nVal) + { + return (*value) == nVal; + } + + bool operator!=(T nVal) + { + return (*value) != nVal; + } + + bool operator<(T nVal) + { + return (*value) < nVal; + } + + bool operator<=(T nVal) + { + return (*value) <= nVal; + } + + bool operator>(T nVal) + { + return (*value) > nVal; + } + + bool operator>=(T nVal) + { + return (*value) >= nVal; + } + + T operator&&(T nVal) + { + return (*value) && nVal; + } + + T operator||(T nVal) + { + return (*value) && nVal; + } + + T operator!() + { + return !(*value); + } + + //Bitwise operations + T operator&(T nVal) + { + return (*value) && nVal; + } + + T operator|(T nVal) + { + return (*value) && nVal; + } + + T operator>>(T nVal) + { + return (*value) >> nVal; + } + + T operator<<(T nVal) + { + return (*value) << nVal; + } + + T operator^(T nVal) + { + return (*value) ^ nVal; + } + + T operator~() + { + return ~(*value); + } \ No newline at end of file diff --git a/src/source/DataModelV3/DataModelInstance.cpp b/src/source/DataModelV3/DataModelInstance.cpp index 3022002..6f269c7 100644 --- a/src/source/DataModelV3/DataModelInstance.cpp +++ b/src/source/DataModelV3/DataModelInstance.cpp @@ -5,6 +5,8 @@ DataModelInstance::DataModelInstance(void) { // Instances Instance::Instance("DataModel"); + name = "Level"; + parentDataModel = this; //workspace = new WorkspaceInstance(); //guiRoot = new GuiRootInstance(); diff --git a/src/source/DataModelV3/LevelInstance.cpp b/src/source/DataModelV3/LevelInstance.cpp index 370cf94..a89b028 100644 --- a/src/source/DataModelV3/LevelInstance.cpp +++ b/src/source/DataModelV3/LevelInstance.cpp @@ -5,7 +5,7 @@ using namespace B3D; LevelInstance::LevelInstance(void) { Instance::Instance("LevelService"); - *name.value = "Level"; + name = "Level"; //Reflection values winMessage = Reflection::ReflectionProperty("WinMessage", "You Won!", TYPE_STRING, this->dataTable); @@ -54,24 +54,24 @@ void LevelInstance::drawCondition() void LevelInstance::Step(SimTime sdt) { - switch(*timerAffectsScore.value) + switch(timerAffectsScore.getValue()) { case Enum::AffectType::NoChange: break; case Enum::AffectType::Increase: - *score.value += 1; + score += 1; break; case Enum::AffectType::Decrease: - if (*score.value > 0) - *score.value -= 1; + if (score > 0) + score -= 1; break; } - if (*timer.value >= sdt){ - *score.value -= sdt; + if (timer >= sdt){ + score -= sdt; } else{ - *timer.value = 0.0f; - switch(*timerUpAction.value) + timer = 0.0f; + switch(timerUpAction.getValue()) { case Enum::ActionType::Nothing: break; diff --git a/src/source/DataModelV3/PartInstance.cpp b/src/source/DataModelV3/PartInstance.cpp index 46a4133..e02d35e 100644 --- a/src/source/DataModelV3/PartInstance.cpp +++ b/src/source/DataModelV3/PartInstance.cpp @@ -17,7 +17,7 @@ PartInstance::PartInstance(void) { PVInstance::PVInstance("Part"); - *(name.value) = "Unnamed PVItem"; + name = "Unnamed PVItem"; canCollide = ReflectionProperty("CanCollide", true, TYPE_BOOLEAN, this->dataTable); anchored = ReflectionProperty("Anchored", false, TYPE_BOOLEAN, this->dataTable); size = ReflectionProperty("Size", Vector3(2,1,4), TYPE_VECTOR3, this->dataTable); @@ -71,7 +71,7 @@ void PartInstance::setDragging(bool value) float PartInstance::getMass() { - if(*(shape.value) == Enum::Shape::Block) + if(shape == Enum::Shape::Block) return size.value->x*size.value->y*size.value->z*0.7F; else return 1.3333333333333333333333333333333F*(size.value->x/2)*(size.value->y/2)*(size.value->z/2)*0.7F; @@ -79,46 +79,46 @@ float PartInstance::getMass() Vector3 PartInstance::getVelocity() { - return *(velocity.value); + return velocity.getValue(); } Vector3 PartInstance::getRotVelocity() { - return *(rotVelocity.value); + return rotVelocity.getValue(); } // OnTouch bool PartInstance::isSingleShot() { - return *(singleShot.value); + return singleShot.getValue(); } int PartInstance::getTouchesToTrigger() { - return *(touchesToTrigger.value); + return touchesToTrigger.getValue(); } int PartInstance::getUniqueObjectsToTrigger() { - return *(uniqueObjectsToTrigger.value); + return uniqueObjectsToTrigger.getValue(); } int PartInstance::getChangeScore() { - return *(changeScore.value); + return changeScore.getValue(); } float PartInstance::getChangeTimer() { - return *(changeTimer.value); + return changeTimer.getValue(); } void PartInstance::setVelocity(Vector3 v) { - *(velocity.value) = v; + velocity = v; } void PartInstance::setRotVelocity(Vector3 v) { - *(rotVelocity.value) = v; + rotVelocity = v; } void PartInstance::postRender(RenderDevice *rd) @@ -128,7 +128,7 @@ void PartInstance::postRender(RenderDevice *rd) void PartInstance::renderName(RenderDevice *rd) { - if(!*(nameShown.value)) + if(!nameShown) return; G3D::GFontRef fnt = NULL; Instance* dm = parent; @@ -143,7 +143,7 @@ void PartInstance::renderName(RenderDevice *rd) } if(!fnt.isNull()) { - Vector3 gamepoint = *(position.value) + Vector3(0,1.5,0); + Vector3 gamepoint = position + Vector3(0,1.5,0); Vector3 camerapoint = rd->getCameraToWorldMatrix().translation; float distance = pow(pow((double)gamepoint.x - (double)camerapoint.x, 2) + pow((double)gamepoint.y - (double)camerapoint.y, 2) + pow((double)gamepoint.z - (double)camerapoint.z, 2), 0.5); if(distance < 100 && distance > -100) @@ -151,7 +151,7 @@ void PartInstance::renderName(RenderDevice *rd) if(distance < 0) distance = distance*-1; glDisable(GL_DEPTH_TEST); - fnt->draw3D(rd, *(name.value), CoordinateFrame(rd->getCameraToWorldMatrix().rotation, gamepoint), 0.03*distance, Color3::yellow(), Color3::black(), G3D::GFont::XALIGN_CENTER, G3D::GFont::YALIGN_CENTER); + fnt->draw3D(rd, name.getValue(), CoordinateFrame(rd->getCameraToWorldMatrix().rotation, gamepoint), 0.03*distance, Color3::yellow(), Color3::black(), G3D::GFont::XALIGN_CENTER, G3D::GFont::YALIGN_CENTER); glEnable(GL_DEPTH_TEST); } } @@ -167,22 +167,22 @@ void PartInstance::setSurface(int face, Enum::SurfaceType::Value surface) switch(face) { case TOP: - *(top.value) = surface; + top = surface; break; case BOTTOM: - *(bottom.value) = surface; + bottom = surface; break; case LEFT: - *(left.value) = surface; + left = surface; break; case RIGHT: - *(right.value) = surface; + right = surface; break; case FRONT: - *(front.value) = surface; + front = surface; break; default: - *(back.value) = surface; + back = surface; } changed = true; } @@ -243,7 +243,7 @@ void PartInstance::setSize(Vector3 newSize) if(sizez > 512) sizez = 512; - if(*(shape.value) != Enum::Shape::Block) + if(shape != Enum::Shape::Block) { int max = sizex; if(sizey > max) @@ -253,28 +253,28 @@ void PartInstance::setSize(Vector3 newSize) sizex = sizey = sizez = max; } - *(size.value) = Vector3(sizex, sizey, sizez); + size = Vector3(sizex, sizey, sizez); if(this->physBody != NULL && getParentDataModel() != NULL) getParentDataModel()->getEngine()->resetBody(this); } Vector3 PartInstance::getSize() { - return *(size.value); + return size.getValue(); } Vector3 PartInstance::getPosition() { - return *(position.value); + return position.getValue(); } void PartInstance::setShape(Enum::Shape::Value shape) { switch(shape) { case Enum::Shape::Block: - *(this->shape.value) = shape; + this->shape = shape; break; default: - *(this->shape.value) = shape; + this->shape = shape; this->setSize(this->getSize()); } if(this->physBody != NULL && getParentDataModel() != NULL) @@ -285,23 +285,23 @@ void PartInstance::setShape(Enum::Shape::Value shape) void PartInstance::setPosition(Vector3 pos) { - *(position.value) = pos; + position = pos; setCFrame(CoordinateFrame(cFrame.value->rotation, pos)); - if (*(anchored.value) && getParentDataModel() != NULL) + if (anchored && getParentDataModel() != NULL) getParentDataModel()->getEngine()->resetBody(this); } void PartInstance::setAnchored(bool anchored) { - *(this->anchored.value) = anchored; + this->anchored = anchored; if(this->physBody != NULL && getParentDataModel() != NULL) getParentDataModel()->getEngine()->resetBody(this); } bool PartInstance::isAnchored() { - return *(this->anchored.value); + return this->anchored.getValue(); } @@ -318,22 +318,22 @@ void PartInstance::setCFrame(CoordinateFrame coordinateFrame) void PartInstance::setCFrameNoSync(CoordinateFrame coordinateFrame) { - *(cFrame.value) = coordinateFrame; - *(position.value) = coordinateFrame.translation; + cFrame = coordinateFrame; + position = coordinateFrame.translation; } bool PartInstance::collides(PartInstance * part) { - if(*(shape.value) == Enum::Shape::Block) + if(shape == Enum::Shape::Block) { - if(*(part->shape.value) == Enum::Shape::Block) + if(part->shape == Enum::Shape::Block) return G3D::CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(getBox(), part->getBox()); else return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidBox(part->getSphere(), getBox()); } else { - if(*(part->shape.value) == Enum::Shape::Block) + if(part->shape == Enum::Shape::Block) return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidBox(getSphere(), part->getBox()); else return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidSphere(getSphere(), part->getSphere()); @@ -364,18 +364,18 @@ void PartInstance::render(RenderDevice* rd) { if (changed) { changed=false; - Vector3 renderSize = *(size.value)/2; + Vector3 renderSize = size.getValue()/2; glNewList(glList, GL_COMPILE); - renderShape(*(this->shape.value), renderSize, *(color.value)); - renderSurface(TOP, *(this->top.value), renderSize, *(this->controller.value), *(color.value)); - renderSurface(FRONT, *(this->front.value), renderSize, *(this->controller.value), *(color.value)); - renderSurface(RIGHT, *(this->right.value), renderSize, *(this->controller.value), *(color.value)); - renderSurface(BACK, *(this->back.value), renderSize, *(this->controller.value), *(color.value)); - renderSurface(LEFT, *(this->left.value), renderSize, *(this->controller.value), *(color.value)); - renderSurface(BOTTOM, *(this->bottom.value), renderSize, *(this->controller.value), *(color.value)); + renderShape(this->shape.getValue(), renderSize, color.getValue()); + renderSurface(TOP, this->top.getValue(), renderSize, this->controller.getValue(), color.getValue()); + renderSurface(FRONT, this->front.getValue(), renderSize, this->controller.getValue(), color.getValue()); + renderSurface(RIGHT, this->right.getValue(), renderSize, this->controller.getValue(), color.getValue()); + renderSurface(BACK, this->back.getValue(), renderSize, this->controller.getValue(), color.getValue()); + renderSurface(LEFT, this->left.getValue(), renderSize, this->controller.getValue(), color.getValue()); + renderSurface(BOTTOM, this->bottom.getValue(), renderSize, this->controller.getValue(), color.getValue()); glEndList(); } - rd->setObjectToWorldMatrix(*(cFrame.value)); + rd->setObjectToWorldMatrix(cFrame.getValue()); glCallList(glList); postRender(rd); } @@ -399,16 +399,16 @@ void PartInstance::onTouch() { if(getParentDataModel() == NULL) return; - if(*(singleShot.value) && _touchedOnce) + if(singleShot && _touchedOnce) return; - if(*(singleShot.value) && !_touchedOnce) + if(singleShot && !_touchedOnce) _touchedOnce = true; - *(getParentDataModel()->getLevel()->score.value) += *(changeScore.value); - *(getParentDataModel()->getLevel()->timer.value) += *(changeTimer.value); + getParentDataModel()->getLevel()->score += changeScore.getValue(); + getParentDataModel()->getLevel()->timer += changeTimer.getValue(); - switch(*(onTouchAction.value)) + switch(onTouchAction.getValue()) { case Enum::ActionType::Nothing: break; diff --git a/src/source/DataModelV3/XplicitNgine/XplicitNgine.cpp b/src/source/DataModelV3/XplicitNgine/XplicitNgine.cpp index f353355..9d99e5e 100644 --- a/src/source/DataModelV3/XplicitNgine/XplicitNgine.cpp +++ b/src/source/DataModelV3/XplicitNgine/XplicitNgine.cpp @@ -22,7 +22,7 @@ XplicitNgine::XplicitNgine() dWorldSetAutoDisableAngularThreshold(physWorld, 0.5F); dWorldSetAutoDisableSteps(physWorld, 20); - *(this->name.value) = "PhysicsService"; + this->name = "PhysicsService"; } XplicitNgine::~XplicitNgine()