diff --git a/src/creatureviewer/main_cw.cpp b/src/creatureviewer/main_cw.cpp
index 95b53c5..0f297ac 100644
--- a/src/creatureviewer/main_cw.cpp
+++ b/src/creatureviewer/main_cw.cpp
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with Genecraft-Project. If not, see .
*/
-#include
+#include
#include "genecraftcoreclasses.h"
@@ -30,9 +30,8 @@ along with Genecraft-Project. If not, see .
#include "ressources/ressourcesmanager.h"
#include
-#include
-#include
#include
+#include
#ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h"
diff --git a/src/genecraft/apps/genecraft/creatureviewer/inputlisteners/creatureviewerinputmanager.cpp b/src/genecraft/apps/genecraft/creatureviewer/inputlisteners/creatureviewerinputmanager.cpp
index 5055b95..75964f4 100644
--- a/src/genecraft/apps/genecraft/creatureviewer/inputlisteners/creatureviewerinputmanager.cpp
+++ b/src/genecraft/apps/genecraft/creatureviewer/inputlisteners/creatureviewerinputmanager.cpp
@@ -157,7 +157,7 @@ void CreatureViewerInputManager::pickBody()
world->getBulletWorld()->rayTest(rayFrom,rayTo,rayCallback);
if (rayCallback.hasHit())
{
- btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
+ const btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
if(body) {
diff --git a/src/genecraft/apps/genecraft/creatureviewer/ui/creatureviewerwindow.cpp b/src/genecraft/apps/genecraft/creatureviewer/ui/creatureviewerwindow.cpp
index db78961..76f2b2e 100644
--- a/src/genecraft/apps/genecraft/creatureviewer/ui/creatureviewerwindow.cpp
+++ b/src/genecraft/apps/genecraft/creatureviewer/ui/creatureviewerwindow.cpp
@@ -312,7 +312,7 @@ void CreatureViewerWindow::init() {
expCtrl = new ExperimentCtrl();
this->ui->dwExperiment->setWidget(expCtrl);
expCtrl->connectToInspectorInputManager(cvim);
- //connect(expCtrl, SIGNAL(addEntity(QVariantMap, Ressource*)), this, SLOT(addResult(QVariantMap,Ressource*)));
+ //connect(expCtrl, SIGNAL(addEntity(QJsonObject, Ressource*)), this, SLOT(addResult(QJsonObject,Ressource*)));
// ----------------------------------
// -- Connections to input manager --
@@ -328,8 +328,8 @@ void CreatureViewerWindow::init() {
connect(cvim,SIGNAL(sLoadExperiment(Experiment*)),this,SLOT(setExperiment(Experiment*)));
connect(this,SIGNAL(sLoadExperiment(Experiment*)),cvim,SLOT(loadExperiment(Experiment*)),Qt::DirectConnection);
emit sLoadExperiment(experiment);
- connect(cvim,SIGNAL(sLoadWorld(QVariantMap)),this,SLOT(setWorld(QVariantMap)));
- connect(cvim,SIGNAL(sLoadEntity(QVariantMap,Ressource*)),this,SLOT(addEntity(QVariantMap,Ressource*)));
+ connect(cvim,SIGNAL(sLoadWorld(QJsonObject)),this,SLOT(setWorld(QJsonObject)));
+ connect(cvim,SIGNAL(sLoadEntity(QJsonObject,Ressource*)),this,SLOT(addEntity(QJsonObject,Ressource*)));
connect(cvim,SIGNAL(sLoadResult(Result*)),this,SLOT(loadResult(Result*)));
// --------------
@@ -405,7 +405,7 @@ void CreatureViewerWindow::setExperiment(Experiment* experiment)
simulationManager->setStatus(status);
}
-void CreatureViewerWindow::setWorld(QVariantMap worldMap) {
+void CreatureViewerWindow::setWorld(QJsonObject worldMap) {
bool status = simulationManager->status();
this->simulationManager->stop();
if(experiment != NULL) {
@@ -420,7 +420,7 @@ void CreatureViewerWindow::loadResult(Result *result) {
this->simulationManager->stop();
setExperiment(experiment);
- QVariantMap genome = result->getGenome().toMap();
+ QJsonObject genome = result->getGenome();
Entity* e = createCreature(genome, world->getSpawnPosition(), result->getRessource());
if(this->experiment->getOnlyIfEntityIsStable())
@@ -509,7 +509,7 @@ void CreatureViewerWindow::spawnMutationSample(Entity *originEntity, int nbCreat
EntitiesEngine *entitiesEngine = static_cast(factory->getEngines().find("Entities").value());
//entitiesEngine->addEntity(originEntity);
//ents.append(originEntity);
- QVariant originGenome = originEntity->serialize();
+ QJsonObject originGenome = originEntity->serialize();
// circle
btScalar r = 3 * nbCreatures;
@@ -518,7 +518,7 @@ void CreatureViewerWindow::spawnMutationSample(Entity *originEntity, int nbCreat
// mutations
for(int i = 0; i < nbCreatures; i++) {
- QVariant newGenome = experiment->getMutationsManager()->mutateEntity(originGenome);
+ QJsonObject newGenome = experiment->getMutationsManager()->mutateEntity(originGenome);
btVector3 pos(sin(i*angle)*r,5,cos(i*angle)*r); //pos(0, 0, i*15 + 15);//
@@ -619,11 +619,11 @@ Entity * CreatureViewerWindow::createNewEntity()
return e;
}
-void CreatureViewerWindow::addEntity(QVariantMap entityData,Ressource *ressource) {
+void CreatureViewerWindow::addEntity(QJsonObject entityData,Ressource *ressource) {
createCreature(entityData, getCameraPosition(), ressource);
}
-//void CreatureViewerWindow::addResult(QVariantMap resultData, Ressource *ressource) {
+//void CreatureViewerWindow::addResult(QJsonObject resultData, Ressource *ressource) {
// Entity* e = createCreature(resultData, world->getSpawnPosition(), ressource);
// e->addOutScript(0, fromNormal); // Normal position during stability time
// e->addOutScript(resultData["stable"].toInt(), fromBrain); // Next from brain
@@ -643,7 +643,7 @@ void CreatureViewerWindow::loadEntityFromFile()
// Load Generic Entity
Ressource* from = new JsonFile(selectedFile);
- QVariant genotype = from->load();
+ QJsonObject genotype = from->load();
Entity *e = createCreature(genotype, getCameraPosition(),from);
@@ -654,7 +654,7 @@ void CreatureViewerWindow::loadEntityFromFile()
simulationManager->start();
}
-Entity * CreatureViewerWindow::createCreature(QVariant genotype, btVector3 position, Ressource *ressource) {
+Entity * CreatureViewerWindow::createCreature(QJsonObject genotype, btVector3 position, Ressource *ressource) {
Entity *e = CreatureFactory::createEntity(genotype, shapesFactory, position);
diff --git a/src/genecraft/apps/genecraft/creatureviewer/ui/creatureviewerwindow.h b/src/genecraft/apps/genecraft/creatureviewer/ui/creatureviewerwindow.h
index aefa20c..394b45f 100644
--- a/src/genecraft/apps/genecraft/creatureviewer/ui/creatureviewerwindow.h
+++ b/src/genecraft/apps/genecraft/creatureviewer/ui/creatureviewerwindow.h
@@ -69,9 +69,9 @@ public slots:
void showAbout();
// new / load / save entity
- void addEntity(QVariantMap entityData, Ressource *ressource);
+ void addEntity(QJsonObject entityData, Ressource *ressource);
Entity *createNewEntity();
- Entity *createCreature(QVariant genotype, btVector3 position, Ressource *ressource);
+ Entity *createCreature(QJsonObject genotype, btVector3 position, Ressource *ressource);
void loadEntityFromFile();
void saveEntityToFile();
void saveEntityToDb();
@@ -83,9 +83,9 @@ public slots:
// experiment and world
void setExperiment(Experiment* experiment);
- void setWorld(QVariantMap worldMap);
+ void setWorld(QJsonObject worldMap);
void loadResult(Result*);
- //void addResult(QVariantMap resultData, Ressource *ressource);
+ //void addResult(QJsonObject resultData, Ressource *ressource);
// notifications
void entitySelected(Entity *entity);
diff --git a/src/genecraft/apps/genecraft/creatureviewer/ui/welcomewidget.cpp b/src/genecraft/apps/genecraft/creatureviewer/ui/welcomewidget.cpp
index 85eec93..92fb02f 100644
--- a/src/genecraft/apps/genecraft/creatureviewer/ui/welcomewidget.cpp
+++ b/src/genecraft/apps/genecraft/creatureviewer/ui/welcomewidget.cpp
@@ -19,7 +19,6 @@ along with Genecraft-Project. If not, see .
#include "welcomewidget.h"
#include "ui_welcomewidget.h"
-
WelcomeWidget::WelcomeWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::WelcomeWidget)
@@ -36,5 +35,5 @@ WelcomeWidget::~WelcomeWidget()
void WelcomeWidget::backToWelcomePage() {
- ui->webView->setUrl(QUrl("qrc:/help/welcome.html"));
+ //ui->webView->setUrl(QUrl("qrc:/help/welcome.html"));
}
diff --git a/src/genecraft/apps/genecraft/creatureviewer/ui/welcomewidget.ui b/src/genecraft/apps/genecraft/creatureviewer/ui/welcomewidget.ui
index 42622ba..7b31cda 100644
--- a/src/genecraft/apps/genecraft/creatureviewer/ui/welcomewidget.ui
+++ b/src/genecraft/apps/genecraft/creatureviewer/ui/welcomewidget.ui
@@ -1,22 +1,4 @@
-
WelcomeWidget
@@ -39,12 +21,7 @@ along with Genecraft-Project. If not, see .
-
-
-
-
- qrc:/help/welcome.html
-
-
+
-
@@ -56,13 +33,6 @@ along with Genecraft-Project. If not, see .
-
-
- QWebView
- QWidget
-
-
-
diff --git a/src/genecraft/core/engines/bulletogre/bulletogreengine.cpp b/src/genecraft/core/engines/bulletogre/bulletogreengine.cpp
index f4c229b..dab28a4 100644
--- a/src/genecraft/core/engines/bulletogre/bulletogreengine.cpp
+++ b/src/genecraft/core/engines/bulletogre/bulletogreengine.cpp
@@ -23,7 +23,9 @@ along with Genecraft-Project. If not, see .
#include "bullet/bulletengine.h"
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
#include "Ogre.h"
-
+#include "OgreOverlay.h"
+#include "OgreOverlayElement.h"
+#include "OgreOverlayManager.h"
namespace GeneCraftCore {
diff --git a/src/genecraft/core/engines/bulletogre/shapes/btosphere.cpp b/src/genecraft/core/engines/bulletogre/shapes/btosphere.cpp
index 34a8477..b77b296 100644
--- a/src/genecraft/core/engines/bulletogre/shapes/btosphere.cpp
+++ b/src/genecraft/core/engines/bulletogre/shapes/btosphere.cpp
@@ -31,20 +31,19 @@ using namespace Ogre;
int btoSphere::mNumSpheresInstanced = 0;
-btoSphere::btoSphere(btoWorld *world, BulletOgreEngine *btoEngine, btScalar radius, const btTransform &transform, const btScalar density, QVariant params)
+btoSphere::btoSphere(btoWorld *world, BulletOgreEngine *btoEngine, btScalar radius, const btTransform &transform, const btScalar density, QJsonObject params)
:btSphere(world, radius, transform, density)
{
this->btoEngine = btoEngine;
OgreEngine *ogreEngine = btoEngine->getOgreEngine();
- QVariantMap paramsMap = params.toMap();
- if(paramsMap.contains("Material"))
- fixationMaterial = params.toMap()["Material"].toString();
+ if(params.contains("Material"))
+ fixationMaterial = params["Material"].toString();
else
fixationMaterial = "GeneCraft/Fixation/Root";
- if(paramsMap.contains("MaterialOnSelection"))
- fixationSelectedMaterial = params.toMap()["MaterialOnSelection"].toString();
+ if(params.contains("MaterialOnSelection"))
+ fixationSelectedMaterial = params["MaterialOnSelection"].toString();
else
fixationSelectedMaterial = "GeneCraft/Fixation_Selected/Root";
diff --git a/src/genecraft/core/engines/bulletogre/shapes/btosphere.h b/src/genecraft/core/engines/bulletogre/shapes/btosphere.h
index 4565526..4041eee 100644
--- a/src/genecraft/core/engines/bulletogre/shapes/btosphere.h
+++ b/src/genecraft/core/engines/bulletogre/shapes/btosphere.h
@@ -23,14 +23,14 @@ along with Genecraft-Project. If not, see .
#include "genecraftcoreclasses.h"
#include "bullet/shapes/btsphere.h"
#include "Ogre.h"
-#include
+#include
namespace GeneCraftCore {
class btoSphere : public btSphere
{
public:
- btoSphere(btoWorld *world, BulletOgreEngine *btoEngine, btScalar radius, const btTransform &transform, const btScalar density, QVariant params = QVariant());
+ btoSphere(btoWorld *world, BulletOgreEngine *btoEngine, btScalar radius, const btTransform &transform, const btScalar density, QJsonObject params = QJsonObject());
~btoSphere();
void setup();
void setSelected(bool selected);
diff --git a/src/genecraft/core/engines/events/inputlistener.h b/src/genecraft/core/engines/events/inputlistener.h
index 84d9b1d..b84fe39 100644
--- a/src/genecraft/core/engines/events/inputlistener.h
+++ b/src/genecraft/core/engines/events/inputlistener.h
@@ -23,6 +23,7 @@ along with Genecraft-Project. If not, see .
#include
#include
#include
+#include
namespace GeneCraftCore {
diff --git a/src/genecraft/core/engines/events/inspectorsinputmanager.cpp b/src/genecraft/core/engines/events/inspectorsinputmanager.cpp
index 095fe2d..69968cf 100644
--- a/src/genecraft/core/engines/events/inspectorsinputmanager.cpp
+++ b/src/genecraft/core/engines/events/inspectorsinputmanager.cpp
@@ -75,10 +75,10 @@ void InspectorsInputManager::experimentUpdated(Experiment *experiment){
void InspectorsInputManager::loadExperiment(Experiment *experiment){
emit sLoadExperiment(experiment);
}
-void InspectorsInputManager::loadWorld(QVariantMap worldData) {
+void InspectorsInputManager::loadWorld(QJsonObject worldData) {
emit sLoadWorld(worldData);
}
-void InspectorsInputManager::loadEntity(QVariantMap genomeData, Ressource *ressource) {
+void InspectorsInputManager::loadEntity(QJsonObject genomeData, Ressource *ressource) {
emit sLoadEntity(genomeData, ressource);
}
void InspectorsInputManager::loadResult(Result *result) {
diff --git a/src/genecraft/core/engines/events/inspectorsinputmanager.h b/src/genecraft/core/engines/events/inspectorsinputmanager.h
index 393c8ca..2ea227d 100644
--- a/src/genecraft/core/engines/events/inspectorsinputmanager.h
+++ b/src/genecraft/core/engines/events/inspectorsinputmanager.h
@@ -20,6 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef INSPECTORSINPUTMANAGER_H
#define INSPECTORSINPUTMANAGER_H
+#include
#include "genecraftcoreclasses.h"
#include "inputlistener.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
@@ -58,8 +59,8 @@ class InspectorsInputManager : public InputListener
// loading
void sLoadExperiment(Experiment *experiment);
- void sLoadWorld(QVariantMap worldData);
- void sLoadEntity(QVariantMap genomeData, Ressource *ressource);
+ void sLoadWorld(QJsonObject worldData);
+ void sLoadEntity(QJsonObject genomeData, Ressource *ressource);
void sLoadResult(Result*);
@@ -85,8 +86,8 @@ public slots:
// loading
void loadExperiment(Experiment *experiment);
- void loadWorld(QVariantMap worldData);
- void loadEntity(QVariantMap genomeData, Ressource *ressource);
+ void loadWorld(QJsonObject worldData);
+ void loadEntity(QJsonObject genomeData, Ressource *ressource);
void loadResult(Result *result);
};
diff --git a/src/genecraft/core/engines/ogre/ogreengine.cpp b/src/genecraft/core/engines/ogre/ogreengine.cpp
index e9df557..9f3fa4f 100644
--- a/src/genecraft/core/engines/ogre/ogreengine.cpp
+++ b/src/genecraft/core/engines/ogre/ogreengine.cpp
@@ -25,6 +25,9 @@ along with Genecraft-Project. If not, see .
#include "Ogre.h"
+#include "OgreOverlay.h"
+#include "OgreOverlayManager.h"
+#include "OgreOverlayContainer.h"
#include "OgreTextAreaOverlayElement.h"
namespace GeneCraftCore {
diff --git a/src/genecraft/core/engines/ogre/ogrewidget.cpp b/src/genecraft/core/engines/ogre/ogrewidget.cpp
index a579677..eb75000 100644
--- a/src/genecraft/core/engines/ogre/ogrewidget.cpp
+++ b/src/genecraft/core/engines/ogre/ogrewidget.cpp
@@ -23,6 +23,9 @@ along with Genecraft-Project. If not, see .
#include "bullet/bulletengine.h"
#include "ogre/ogreengine.h"
+#if defined(Q_WS_X11)
+ #include
+#endif
using namespace Ogre;
namespace GeneCraftCore {
diff --git a/src/genecraft/core/engines/ogre/ogrewidget.h b/src/genecraft/core/engines/ogre/ogrewidget.h
index e43a793..db16254 100644
--- a/src/genecraft/core/engines/ogre/ogrewidget.h
+++ b/src/genecraft/core/engines/ogre/ogrewidget.h
@@ -21,7 +21,6 @@ along with Genecraft-Project. If not, see .
#define OGREWIDGET_H
#include
-#include
#include
#include
#include "genecraftcoreclasses.h"
diff --git a/src/genecraft/core/engines/terrain/terrain.cpp b/src/genecraft/core/engines/terrain/terrain.cpp
index 6404d25..29aed5e 100644
--- a/src/genecraft/core/engines/terrain/terrain.cpp
+++ b/src/genecraft/core/engines/terrain/terrain.cpp
@@ -132,7 +132,7 @@ namespace GeneCraftCore {
}
}
- TerrainData* Terrain::addTerrain(QVariantMap floorData) {
+ TerrainData* Terrain::addTerrain(QJsonObject floorData) {
TerrainData* terrain = new TerrainData();
terrain->floorData = floorData;
@@ -154,15 +154,15 @@ namespace GeneCraftCore {
// Loading eventual step width
if(floorData.contains("width")) {
- terrain->width = floorData["width"].toFloat();
+ terrain->width = floorData["width"].toDouble();
} else {
terrain->width = 1;
}
// Loading eventual step height
if(floorData.contains("minHeight")) {
- float minHeight = floorData["minHeight"].toFloat();
- float maxHeight = floorData["maxHeight"].toFloat();
+ float minHeight = floorData["minHeight"].toDouble();
+ float maxHeight = floorData["maxHeight"].toDouble();
terrain->height = (minHeight + maxHeight) / 2.;
terrain->randomHeight = maxHeight - minHeight;
} else {
diff --git a/src/genecraft/core/engines/terrain/terrain.h b/src/genecraft/core/engines/terrain/terrain.h
index 719237f..3752053 100644
--- a/src/genecraft/core/engines/terrain/terrain.h
+++ b/src/genecraft/core/engines/terrain/terrain.h
@@ -25,7 +25,7 @@ along with Genecraft-Project. If not, see .
#include "engine.h"
#include "entities/entitiesengine.h"
#include
-#include
+#include
namespace GeneCraftCore {
@@ -47,7 +47,7 @@ namespace GeneCraftCore {
*/
enum FloorType { NoFloor, FlatLand, RandomBoxes, StairsUp, StairsDown, Slope };
FloorType floor; /**< the type of the field */
- QVariantMap floorData; /**< the configurations informations from the field */
+ QJsonObject floorData; /**< the configurations informations from the field */
/**
* @brief simple comparator, return true if the field is of the same type
@@ -97,7 +97,7 @@ namespace GeneCraftCore {
*
* @param floorData
*/
- TerrainData* addTerrain(QVariantMap floorData);
+ TerrainData* addTerrain(QJsonObject floorData);
/**
* @brief Remove a field from the engine
*
diff --git a/src/genecraft/core/entities/body/bone.cpp b/src/genecraft/core/entities/body/bone.cpp
index 48fa36d..5822e59 100644
--- a/src/genecraft/core/entities/body/bone.cpp
+++ b/src/genecraft/core/entities/body/bone.cpp
@@ -42,6 +42,7 @@ along with Genecraft-Project. If not, see .
// World
#include "bullet/btworld.h"
+#include
namespace GeneCraftCore {
@@ -50,7 +51,7 @@ Bone::Bone(btShapesFactory *shapesFactory, btScalar yAxis, btScalar zAxis, btSca
: QObject(), yAxis(yAxis), zAxis(zAxis), parentFix(NULL), motorsEffector(NULL)
{
- motorModifierData = QVariant();
+ motorModifierData = QJsonObject();
parentCt = 0;
body = shapesFactory->createBone(length, radius, endFixRadius, initTransform);
rigidBody = body->getRigidBody();
@@ -133,8 +134,8 @@ void Bone::setup()
// add motor modifier
- if(motorModifierData != QVariant()) {
- QVariantMap motor = motorModifierData.toMap();
+ if(motorModifierData != QJsonObject()) {
+ QJsonObject motor = motorModifierData;
if(!motor.contains("typename")) {
motor.insert("typename", "Rotational Motor");
motor.insert("type", (int)rotationalMotorEffector);
@@ -258,33 +259,33 @@ void Bone::setZAxis(btScalar zAxis) {
// -- SERIALIZATION --
// -------------------
-QVariant Bone::serialize()
+QJsonObject Bone::serialize()
{
- QVariantMap bone;
+ QJsonObject bone;
// Length & radius
- bone.insert("length",QVariant((double)getLength()));
- bone.insert("radius",QVariant((double)getRadius()));
+ bone.insert("length",(double)getLength());
+ bone.insert("radius",(double)getRadius());
// Yaw & Roll
- QVariantMap localRotation;
- localRotation.insert("y",QVariant((double)getYAxis()));
- localRotation.insert("z",QVariant((double)getZAxis()));
+ QJsonObject localRotation;
+ localRotation.insert("y",(double)getYAxis());
+ localRotation.insert("z",(double)getZAxis());
bone.insert("localRotation",localRotation);
// Limits
- QVariantMap lowerlimits, upperlimits;
+ QJsonObject lowerlimits, upperlimits;
btVector3 angularLowerLimits, angularUpperLimits;
parentCt->getAngularLowerLimit(angularLowerLimits);
parentCt->getAngularUpperLimit(angularUpperLimits);
- lowerlimits.insert("x",QVariant((double)angularLowerLimits.x()));
- lowerlimits.insert("y",QVariant((double)angularLowerLimits.y()));
- lowerlimits.insert("z",QVariant((double)angularLowerLimits.z()));
+ lowerlimits.insert("x",(double)angularLowerLimits.x());
+ lowerlimits.insert("y",(angularLowerLimits.y()));
+ lowerlimits.insert("z",(double)angularLowerLimits.z());
- upperlimits.insert("x",QVariant((double)angularUpperLimits.x()));
- upperlimits.insert("y",QVariant((double)angularUpperLimits.y()));
- upperlimits.insert("z",QVariant((double)angularUpperLimits.z()));
+ upperlimits.insert("x",(double)angularUpperLimits.x());
+ upperlimits.insert("y",(double)angularUpperLimits.y());
+ upperlimits.insert("z",(double)angularUpperLimits.z());
bone.insert("lowerLimits",lowerlimits);
bone.insert("upperLimits",upperlimits);
@@ -298,23 +299,23 @@ QVariant Bone::serialize()
return bone;
}
-QVariant Bone::generateEmpty() {
+QJsonObject Bone::generateEmpty() {
- QVariantMap bone;
+ QJsonObject bone;
// TODO right values ???
// Length & radius
- bone.insert("length",QVariant((double)Tools::random(0.5,3.0)));
- bone.insert("radius",QVariant((double)Tools::random(0.1,0.5)));
+ bone.insert("length",(double)Tools::random(0.5,3.0));
+ bone.insert("radius",(double)Tools::random(0.1,0.5));
// Yaw & Roll
- QVariantMap localRotation;
- localRotation.insert("y",QVariant((double)Tools::random(-SIMD_PI,SIMD_PI)));
- localRotation.insert("z",QVariant((double)Tools::random(-SIMD_PI,SIMD_PI)));
+ QJsonObject localRotation;
+ localRotation.insert("y",(double)Tools::random(-SIMD_PI,SIMD_PI));
+ localRotation.insert("z",(double)Tools::random(-SIMD_PI,SIMD_PI));
bone.insert("localRotation",localRotation);
// Limits
- QVariantMap lowerlimits, upperlimits;
+ QJsonObject lowerlimits, upperlimits;
btScalar lowerLimit_x = Tools::random(-SIMD_PI/6., 0.);
btScalar lowerLimit_y = Tools::random(-SIMD_PI/6., 0.);
@@ -324,9 +325,9 @@ QVariant Bone::generateEmpty() {
btScalar upperlimits_y = Tools::random(0., SIMD_PI/6.);
btScalar upperlimits_z = Tools::random(0., SIMD_PI/6.);
- lowerlimits.insert("x",QVariant((double)lowerLimit_x));
- lowerlimits.insert("y",QVariant((double)lowerLimit_y));
- lowerlimits.insert("z",QVariant((double)lowerLimit_z));
+ lowerlimits.insert("x",(double)lowerLimit_x);
+ lowerlimits.insert("y",(double)lowerLimit_y);
+ lowerlimits.insert("z",(double)lowerLimit_z);
upperlimits.insert("x",(double)upperlimits_x);
upperlimits.insert("y",(double)upperlimits_y);
@@ -338,7 +339,7 @@ QVariant Bone::generateEmpty() {
// End fixation
bone.insert("endFix",Fixation::generateEmpty());
- QVariantMap data;
+ QJsonObject data;
data.insert("typeName", "RotationalMotor");
data.insert("type", rotationalMotorEffector);
@@ -359,15 +360,15 @@ QVariant Bone::generateEmpty() {
"type":"RotationalMotor"}*/
// TODO DO IT BETHER
- QVariantMap bOuts;
+ QJsonObject bOuts;
QString motors[] = {"x","y","z"};
- QVariantMap emptyOut;
+ QJsonObject emptyOut;
emptyOut.insert("connexionInfo", "");
- QVariantList emptyOutList;
+ QJsonArray emptyOutList;
emptyOutList.append(emptyOut);
emptyOutList.append(emptyOut);
for(int i = 0; i < 3; i++) {
- QVariantMap motorMap;
+ QJsonObject motorMap;
motorMap.insert("brainOuts", emptyOutList);
bOuts.insert(motors[i], motorMap);
}
diff --git a/src/genecraft/core/entities/body/bone.h b/src/genecraft/core/entities/body/bone.h
index 210a7dd..09e3e39 100644
--- a/src/genecraft/core/entities/body/bone.h
+++ b/src/genecraft/core/entities/body/bone.h
@@ -21,7 +21,7 @@ along with Genecraft-Project. If not, see .
#define BONE_H
#include
-#include
+#include
#include "genecraftcoreclasses.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
@@ -76,12 +76,12 @@ class Bone : public QObject
* @brief create the basic genetic code for this bone
*
*/
- QVariant serialize();
+ QJsonObject serialize();
/**
* @brief create an empty piece of genetics for a bone
*
*/
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// -------------------------
// -- getters and setters --
@@ -145,7 +145,7 @@ class Bone : public QObject
*
* @param data genetic code for the brain needed data
*/
- inline void setMotorModifierData(QVariant data) { this->motorModifierData = data; }
+ inline void setMotorModifierData(QJsonObject data) { this->motorModifierData = data; }
// body & size
/**
@@ -277,7 +277,7 @@ class Bone : public QObject
btGeneric6DofConstraint *parentCt; // Owner /**< TODO */
// MotorModifier data
- QVariant motorModifierData; /**< TODO */
+ QJsonObject motorModifierData; /**< TODO */
// Related Entity
Entity *entity; /**< TODO */
diff --git a/src/genecraft/core/entities/body/fixation.cpp b/src/genecraft/core/entities/body/fixation.cpp
index f6c9d20..9e7cf7e 100644
--- a/src/genecraft/core/entities/body/fixation.cpp
+++ b/src/genecraft/core/entities/body/fixation.cpp
@@ -21,7 +21,7 @@ along with Genecraft-Project. If not, see .
// Qt
#include
-#include
+#include
// Engine
#include "bullet/bulletengine.h"
@@ -400,14 +400,14 @@ namespace GeneCraftCore {
// -- SERIALIZATION --
// -------------------
- QVariant Fixation::serialize()
+ QJsonObject Fixation::serialize()
{
- QVariantMap fixation;
- QVariantList bonesVariantList;
- QVariantList sensorsVariantList;
- QVariantList effectorsVariantList;
+ QJsonObject fixation;
+ QJsonArray bonesVariantList;
+ QJsonArray sensorsVariantList;
+ QJsonArray effectorsVariantList;
- fixation.insert("radius",QVariant((double)radius));
+ fixation.insert("radius", (double)radius);
foreach(Bone *bone, bones) {
bonesVariantList.append(bone->serialize());
@@ -428,15 +428,15 @@ namespace GeneCraftCore {
return fixation;
}
- QVariant Fixation::generateEmpty()
+ QJsonObject Fixation::generateEmpty()
{
- QVariantMap fixation;
+ QJsonObject fixation;
// TODO right values ???
fixation.insert("radius",(double) Tools::random(0.1,0.5));
- fixation.insert("bones", QVariantList());
- fixation.insert("sensors", QVariantList());
- fixation.insert("effectors", QVariantList());
+ fixation.insert("bones", QJsonArray());
+ fixation.insert("sensors", QJsonArray());
+ fixation.insert("effectors", QJsonArray());
return fixation;
}
diff --git a/src/genecraft/core/entities/body/fixation.h b/src/genecraft/core/entities/body/fixation.h
index a6dde4a..823010d 100644
--- a/src/genecraft/core/entities/body/fixation.h
+++ b/src/genecraft/core/entities/body/fixation.h
@@ -44,10 +44,10 @@ namespace GeneCraftCore {
~Fixation();
// To serialize
- QVariant serialize();
+ QJsonObject serialize();
// To generate an empty serialized version
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// To set default parameters of fixation and add it into engines
void setup();
diff --git a/src/genecraft/core/entities/body/treeshape.cpp b/src/genecraft/core/entities/body/treeshape.cpp
index 59184e4..3d41007 100644
--- a/src/genecraft/core/entities/body/treeshape.cpp
+++ b/src/genecraft/core/entities/body/treeshape.cpp
@@ -19,8 +19,7 @@ along with Genecraft-Project. If not, see .
#include "treeshape.h"
-#include
-#include
+#include
#include "fixation.h"
#include "treeshape.h"
@@ -64,11 +63,11 @@ namespace GeneCraftCore {
getRoot()->setup();
}
- QVariant TreeShape::serialize()
+ QJsonObject TreeShape::serialize()
{
- QVariantMap treeShape, shape;
+ QJsonObject treeShape, shape;
- treeShape.insert("shapeType", QVariant("TreeShape"));
+ treeShape.insert("shapeType", QString("TreeShape"));
shape.insert("rootFix", root->serialize());
treeShape.insert("shape",shape);
diff --git a/src/genecraft/core/entities/body/treeshape.h b/src/genecraft/core/entities/body/treeshape.h
index 7eeb84d..9e00389 100644
--- a/src/genecraft/core/entities/body/treeshape.h
+++ b/src/genecraft/core/entities/body/treeshape.h
@@ -21,6 +21,7 @@ along with Genecraft-Project. If not, see .
#define TREESHAPE_H
#include "genecraftcoreclasses.h"
#include
+#include
#include "LinearMath/btTransform.h"
// TODO: INHERIT : Shape, -> CREATE CLASS SHAPE with method setup AND print
@@ -47,7 +48,7 @@ namespace GeneCraftCore {
*/
void setup();
- QVariant serialize();
+ QJsonObject serialize();
private:
diff --git a/src/genecraft/core/entities/brain/brain.cpp b/src/genecraft/core/entities/brain/brain.cpp
index dd9c146..c63583b 100644
--- a/src/genecraft/core/entities/brain/brain.cpp
+++ b/src/genecraft/core/entities/brain/brain.cpp
@@ -32,9 +32,9 @@ namespace GeneCraftCore {
this->frequency = qrand()%60 + 1;
}
- Brain::Brain(QVariant data) {
+ Brain::Brain(QJsonObject data) {
this->plugGrid = new BrainPlugGrid();
- this->frequency = data.toMap()["frequency"].toInt();
+ this->frequency = data["frequency"].toInt();
if(frequency <= 0) {
frequency = 1;
}
@@ -43,8 +43,8 @@ namespace GeneCraftCore {
}
}
- QVariant Brain::serialize() {
- QVariantMap data;
+ QJsonObject Brain::serialize() {
+ QJsonObject data;
data.insert("frequency", this->frequency);
return data;
}
diff --git a/src/genecraft/core/entities/brain/brain.h b/src/genecraft/core/entities/brain/brain.h
index ea0a496..153d2bf 100644
--- a/src/genecraft/core/entities/brain/brain.h
+++ b/src/genecraft/core/entities/brain/brain.h
@@ -23,7 +23,7 @@ along with Genecraft-Project. If not, see .
#include
#include "genecraftcoreclasses.h"
-#include
+#include
namespace GeneCraftCore {
class Brain : public QObject
@@ -31,7 +31,7 @@ class Brain : public QObject
public:
explicit Brain(QObject *parent = 0);
- Brain(QVariant data);
+ Brain(QJsonObject data);
BrainPlugGrid* getPlugGrid() {
return this->plugGrid;
@@ -41,7 +41,7 @@ class Brain : public QObject
this->plugGrid = plugGrid;
}
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
virtual void step() = 0;
diff --git a/src/genecraft/core/entities/brain/brainfunctional.cpp b/src/genecraft/core/entities/brain/brainfunctional.cpp
index a557eb4..baf8da2 100644
--- a/src/genecraft/core/entities/brain/brainfunctional.cpp
+++ b/src/genecraft/core/entities/brain/brainfunctional.cpp
@@ -54,7 +54,7 @@ btScalar sigmoid(btScalar x)
{
}
- BrainFunctional::BrainFunctional(QVariant data) : Brain(data) {
+ BrainFunctional::BrainFunctional(QJsonObject data) : Brain(data) {
}
@@ -101,13 +101,13 @@ btScalar sigmoid(btScalar x)
break;
case INPUT:
{
- BrainNodeIn* in = new BrainNodeIn(nodePart[1].toFloat(), nodePart[2].toFloat());
+ BrainNodeIn* in = new BrainNodeIn(nodePart[1].toDouble(), nodePart[2].toDouble());
tree.append(in);
this->brainins.append(in); // display purpose
}
break;
case CONSTANT:
- tree.append(new BrainNodeConst(nodePart[1].toFloat()));
+ tree.append(new BrainNodeConst(nodePart[1].toDouble()));
break;
case INTEGRATE:
case INTERPOLATE:
@@ -125,7 +125,7 @@ btScalar sigmoid(btScalar x)
break;
case WAVE:
tree.append(new BrainNode(WAVE));
- tree.append(new BrainNodeConst(nodePart[1].toFloat()));
+ tree.append(new BrainNodeConst(nodePart[1].toDouble()));
tree.append(new BrainMemory(1));
break;
case MEMORY_SPACE:
@@ -536,8 +536,8 @@ btScalar sigmoid(btScalar x)
return func;
}
- QVariant BrainFunctional::serialize() {
- QVariantMap data = Brain::serialize().toMap();
+ QJsonObject BrainFunctional::serialize() {
+ QJsonObject data = Brain::serialize();
return data;
}
}
diff --git a/src/genecraft/core/entities/brain/brainfunctional.h b/src/genecraft/core/entities/brain/brainfunctional.h
index 5e90ba4..8f72a72 100644
--- a/src/genecraft/core/entities/brain/brainfunctional.h
+++ b/src/genecraft/core/entities/brain/brainfunctional.h
@@ -25,7 +25,7 @@ along with Genecraft-Project. If not, see .
#include "brainnode.h"
#include
-#include
+#include
#include
namespace GeneCraftCore {
@@ -34,7 +34,7 @@ class BrainFunctional : public Brain
public:
explicit BrainFunctional(QObject *parent = 0);
- BrainFunctional(QVariant data);
+ BrainFunctional(QJsonObject data);
~BrainFunctional();
void addOut(BrainOut* out);
@@ -46,7 +46,7 @@ class BrainFunctional : public Brain
static QString createRandomFunc(int depth, StructuralList* nodesList = NULL);
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
virtual void step();
diff --git a/src/genecraft/core/entities/brain/brainin.cpp b/src/genecraft/core/entities/brain/brainin.cpp
index e88590a..e284cad 100644
--- a/src/genecraft/core/entities/brain/brainin.cpp
+++ b/src/genecraft/core/entities/brain/brainin.cpp
@@ -19,7 +19,7 @@ along with Genecraft-Project. If not, see .
#include "brainin.h"
#include
-#include
+#include
namespace GeneCraftCore {
@@ -28,13 +28,13 @@ namespace GeneCraftCore {
{
}
- BrainIn::BrainIn(QVariant data) : Synapse(data.toMap()["connexions"]), value(0) {
- min = data.toMap()["min"].toFloat();
- max = data.toMap()["max"].toFloat();
+ BrainIn::BrainIn(QJsonObject data) : Synapse(data["connexions"].toArray()), value(0) {
+ min = data["min"].toDouble();
+ max = data["max"].toDouble();
}
- QVariant BrainIn::serialize() {
- QVariantMap data;
+ QJsonObject BrainIn::serialize() {
+ QJsonObject data;
data.insert("connexions", Synapse::serialize());
data.insert("min", (double)min);
@@ -58,11 +58,11 @@ namespace GeneCraftCore {
return this->value;
}
- QVariant BrainIn::generateEmpty(btScalar min, btScalar max)
+ QJsonObject BrainIn::generateEmpty(btScalar min, btScalar max)
{
- QVariantMap data;
+ QJsonObject data;
- data.insert("connexions", QVariantList());
+ data.insert("connexions", QJsonArray());
data.insert("min", (double)min);
data.insert("max", (double)max);
diff --git a/src/genecraft/core/entities/brain/brainin.h b/src/genecraft/core/entities/brain/brainin.h
index b9e0f05..c8ee011 100644
--- a/src/genecraft/core/entities/brain/brainin.h
+++ b/src/genecraft/core/entities/brain/brainin.h
@@ -21,6 +21,7 @@ along with Genecraft-Project. If not, see .
#define NEURALIN_H
#include
+#include
#include "genecraftcoreclasses.h"
#include "synapse.h"
@@ -32,10 +33,10 @@ namespace GeneCraftCore {
public:
explicit BrainIn(btScalar min = 0.0f, btScalar max = 100.0f, QObject *parent = 0);
- BrainIn(QVariant data);
+ BrainIn(QJsonObject data);
- static QVariant generateEmpty(btScalar min, btScalar max);
- QVariant serialize();
+ static QJsonObject generateEmpty(btScalar min, btScalar max);
+ QJsonObject serialize();
void setMin(btScalar min) { this->min = min; }
void setMax(btScalar max) { this->max = max; }
diff --git a/src/genecraft/core/entities/brain/brainout.cpp b/src/genecraft/core/entities/brain/brainout.cpp
index 7967404..061f2c7 100644
--- a/src/genecraft/core/entities/brain/brainout.cpp
+++ b/src/genecraft/core/entities/brain/brainout.cpp
@@ -27,15 +27,15 @@ namespace GeneCraftCore {
connexionInfo = "";
}
- BrainOut::BrainOut(QVariant data) {
- min = data.toMap()["min"].toFloat();
- max = data.toMap()["max"].toFloat();
- connexionInfo = data.toMap()["connexionInfo"].toString();
+ BrainOut::BrainOut(QJsonObject data) {
+ min = data["min"].toDouble();
+ max = data["max"].toDouble();
+ connexionInfo = data["connexionInfo"].toString();
value = (min + max) / 2.0;
}
- QVariant BrainOut::serialize() {
- QVariantMap data;
+ QJsonObject BrainOut::serialize() {
+ QJsonObject data;
data.insert("min", (double)min);
data.insert("max", (double)max);
@@ -66,11 +66,11 @@ namespace GeneCraftCore {
emit newValue(this->value);
}
- void BrainOut::setConnexionInfo(QVariant info) {
+ void BrainOut::setConnexionInfo(QJsonValue info) {
this->connexionInfo = info;
}
- QVariant BrainOut::getConnexionInfo() {
+ QJsonValue BrainOut::getConnexionInfo() {
return this->connexionInfo;
}
}
diff --git a/src/genecraft/core/entities/brain/brainout.h b/src/genecraft/core/entities/brain/brainout.h
index beda437..f45bd8e 100644
--- a/src/genecraft/core/entities/brain/brainout.h
+++ b/src/genecraft/core/entities/brain/brainout.h
@@ -24,7 +24,7 @@ along with Genecraft-Project. If not, see .
#include
#include "genecraftcoreclasses.h"
-#include
+#include
namespace GeneCraftCore {
@@ -33,8 +33,8 @@ namespace GeneCraftCore {
Q_OBJECT
public:
explicit BrainOut(btScalar min = 0.0f, btScalar max = 100.0f, QObject *parent = 0);
- BrainOut(QVariant data);
- QVariant serialize();
+ BrainOut(QJsonObject data);
+ QJsonObject serialize();
signals:
void newValue(btScalar value);
@@ -49,9 +49,9 @@ namespace GeneCraftCore {
*/
void setValue(btScalar value);
- void setConnexionInfo(QVariant info);
+ void setConnexionInfo(QJsonValue info);
- QVariant getConnexionInfo();
+ QJsonValue getConnexionInfo();
void setMin(btScalar min) { this->min = min; }
void setMax(btScalar max) { this->max = max; }
@@ -60,7 +60,7 @@ namespace GeneCraftCore {
btScalar min;
btScalar max;
btScalar value;
- QVariant connexionInfo;
+ QJsonValue connexionInfo;
};
diff --git a/src/genecraft/core/entities/brain/synapse.cpp b/src/genecraft/core/entities/brain/synapse.cpp
index 6dff3e2..95fe9ed 100644
--- a/src/genecraft/core/entities/brain/synapse.cpp
+++ b/src/genecraft/core/entities/brain/synapse.cpp
@@ -18,7 +18,8 @@ along with Genecraft-Project. If not, see .
*/
#include "synapse.h"
-#include
+#include
+#include
namespace GeneCraftCore {
@@ -27,17 +28,15 @@ namespace GeneCraftCore {
{
}
- Synapse::Synapse(QVariant data) {
+ Synapse::Synapse(QJsonArray data) {
- QVariantList l = data.toList();
-
- foreach(QVariant v, l) {
- btScalar x = v.toMap()["x"].toDouble();
- btScalar y = v.toMap()["y"].toDouble();
- btScalar w = v.toMap()["w"].toDouble();
+ foreach(QJsonValue v, data) {
+ btScalar x = v.toObject()["x"].toDouble();
+ btScalar y = v.toObject()["y"].toDouble();
+ btScalar w = v.toObject()["w"].toDouble();
btScalar distance = 0.0f;
- if(v.toMap().contains("d"))
- distance = v.toMap()["d"].toDouble();
+ if(v.toObject().contains("d"))
+ distance = v.toObject()["d"].toDouble();
else
distance = Tools::random(0.0, 0.2);
@@ -45,13 +44,13 @@ namespace GeneCraftCore {
}
}
- QVariant Synapse::serialize() {
+ QJsonArray Synapse::serialize() {
- QVariantList l;
+ QJsonArray l;
for(int i = 0; i < this->connexions.size(); i++) {
NeuralConnexion c = connexions[i];
- QVariantMap dataC;
+ QJsonObject dataC;
dataC.insert("x", (double)c.x);
dataC.insert("y", (double)c.y);
dataC.insert("w", (double)c.weight);
diff --git a/src/genecraft/core/entities/brain/synapse.h b/src/genecraft/core/entities/brain/synapse.h
index 7bb36e4..6e7a18d 100644
--- a/src/genecraft/core/entities/brain/synapse.h
+++ b/src/genecraft/core/entities/brain/synapse.h
@@ -21,6 +21,7 @@ along with Genecraft-Project. If not, see .
#define SYNAPSE_H
#include
+#include
#include "genecraftcoreclasses.h"
#include
#include "tools.h"
@@ -53,8 +54,8 @@ namespace GeneCraftCore {
public:
explicit Synapse(QObject *parent = 0);
- Synapse(QVariant data);
- QVariant serialize();
+ Synapse(QJsonArray data);
+ QJsonArray serialize();
QList getConnexions();
diff --git a/src/genecraft/core/entities/effectors/brainoutmotor.cpp b/src/genecraft/core/entities/effectors/brainoutmotor.cpp
index c9ce222..de5fbad 100644
--- a/src/genecraft/core/entities/effectors/brainoutmotor.cpp
+++ b/src/genecraft/core/entities/effectors/brainoutmotor.cpp
@@ -19,6 +19,7 @@ along with Genecraft-Project. If not, see .
#include "brainoutmotor.h"
#include
+#include
#include "genecraftcoreclasses.h"
#include "effector.h"
#include "brain/brainout.h"
@@ -37,31 +38,30 @@ namespace GeneCraftCore {
delete this->boTargetVelocity;
}
- BrainOutMotor::BrainOutMotor(QVariant data, btRotationalLimitMotor* motor) : motor(motor){
- QVariantMap outMap = data.toMap();
+ BrainOutMotor::BrainOutMotor(QJsonObject data, btRotationalLimitMotor* motor) : motor(motor){
// new version
- if(outMap.contains("contractionOutput")) {
- boMaxMotorForce = new BrainOut(outMap["contractionOutput"]);
- boTargetVelocity = new BrainOut(outMap["expansionOutput"]);
+ if(data.contains("contractionOutput")) {
+ boMaxMotorForce = new BrainOut(data["contractionOutput"].toObject());
+ boTargetVelocity = new BrainOut(data["expansionOutput"].toObject());
}
// old version
else {
- QVariantList dataL = outMap["brainOuts"].toList();
- boMaxMotorForce = new BrainOut(dataL[0]);
- boTargetVelocity = new BrainOut(dataL[1]);
+ QJsonArray dataL = data["brainOuts"].toArray();
+ boMaxMotorForce = new BrainOut(dataL[0].toObject());
+ boTargetVelocity = new BrainOut(dataL[1].toObject());
}
}
- QVariant BrainOutMotor::serialize() {
+ QJsonObject BrainOutMotor::serialize() {
- QVariantMap data;
+ QJsonObject data;
// old version
- // QVariantList outs;
+ // QJsonArray outs;
// outs.append(boMaxMotorForce->serialize());
// outs.append(boTargetVelocity->serialize());
- // data.insert("brainOuts", (QVariantList)outs);
+ // data.insert("brainOuts", outs);
// new version
data.insert("contractionOutput",boMaxMotorForce->serialize());
@@ -71,9 +71,9 @@ namespace GeneCraftCore {
}
// To generate an empty version
- QVariant BrainOutMotor::generateEmpty(){
+ QJsonObject BrainOutMotor::generateEmpty(){
- QVariantMap data;
+ QJsonObject data;
BrainOut boContraction(MIN_CONTRACTION,MAX_CONTRACTION);
BrainOut boExpansion(MIN_EXPANSION,MAX_EXPANSION);
data.insert("contractionOutput",boContraction.serialize());
diff --git a/src/genecraft/core/entities/effectors/brainoutmotor.h b/src/genecraft/core/entities/effectors/brainoutmotor.h
index 3686962..92d5e3c 100644
--- a/src/genecraft/core/entities/effectors/brainoutmotor.h
+++ b/src/genecraft/core/entities/effectors/brainoutmotor.h
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef BRAINOUTMOTOR_H
#define BRAINOUTMOTOR_H
-#include
+#include
#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"
#include "genecraftcoreclasses.h"
@@ -45,12 +45,12 @@ namespace GeneCraftCore {
~BrainOutMotor();
- BrainOutMotor(QVariant data, btRotationalLimitMotor* motor);
+ BrainOutMotor(QJsonObject data, btRotationalLimitMotor* motor);
- QVariant serialize();
+ QJsonObject serialize();
// To generate an empty version
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
void update();
diff --git a/src/genecraft/core/entities/effectors/effector.cpp b/src/genecraft/core/entities/effectors/effector.cpp
index 59b0943..e7e48f5 100644
--- a/src/genecraft/core/entities/effectors/effector.cpp
+++ b/src/genecraft/core/entities/effectors/effector.cpp
@@ -18,27 +18,27 @@ along with Genecraft-Project. If not, see .
*/
#include "effector.h"
-#include
+#include
namespace GeneCraftCore {
Effector::Effector(QString typeName, EffectorType type) : typeName(typeName), type(type)
{
}
-Effector::Effector(QVariant data) {
- this->typeName = data.toMap()["typeName"].toString();
- this->type = (EffectorType)data.toMap()["type"].toInt();
+Effector::Effector(QJsonObject data) {
+ this->typeName = data["typeName"].toString();
+ this->type = (EffectorType)data["type"].toInt();
}
-QVariant Effector::serialize() {
- QVariantMap data;
+QJsonObject Effector::serialize() {
+ QJsonObject data;
data.insert("typeName", this->typeName);
data.insert("type", (int)this->type);
return data;
}
-QVariant Effector::generateEmpty(QString typeName, int type) {
- QVariantMap data;
+QJsonObject Effector::generateEmpty(QString typeName, int type) {
+ QJsonObject data;
data.insert("typeName", typeName);
data.insert("type", type);
return data;
diff --git a/src/genecraft/core/entities/effectors/effector.h b/src/genecraft/core/entities/effectors/effector.h
index 0e16803..d9b10f9 100644
--- a/src/genecraft/core/entities/effectors/effector.h
+++ b/src/genecraft/core/entities/effectors/effector.h
@@ -21,7 +21,8 @@ along with Genecraft-Project. If not, see .
#define EFFECTOR_H
#include
-#include
+#include
+#include
#include "genecraftcoreclasses.h"
namespace GeneCraftCore {
@@ -48,13 +49,13 @@ class Effector
Effector(QString typeName, EffectorType type);
// To create from serialization data
- Effector(QVariant data);
+ Effector(QJsonObject data);
// To create empty sensor serialization data
- static QVariant generateEmpty(QString typeName, int type);
+ static QJsonObject generateEmpty(QString typeName, int type);
// To serialize
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
// To get the type name
const QString &getTypeName() { return typeName; }
diff --git a/src/genecraft/core/entities/effectors/flyingeffector.cpp b/src/genecraft/core/entities/effectors/flyingeffector.cpp
index bcdb751..756fbed 100644
--- a/src/genecraft/core/entities/effectors/flyingeffector.cpp
+++ b/src/genecraft/core/entities/effectors/flyingeffector.cpp
@@ -41,21 +41,21 @@ FlyingEffector::FlyingEffector(Fixation *fixation) : Effector(QString(TYPE_NAME)
brainOutputs.append(impulseZ);
}
-FlyingEffector::FlyingEffector(QVariant data, Fixation *fixation) : Effector(data), fixation(fixation)
+FlyingEffector::FlyingEffector(QJsonObject data, Fixation *fixation) : Effector(data), fixation(fixation)
{
- QVariantMap outs = data.toMap()["outs"].toMap();
+ QJsonObject outs = data["outs"].toObject();
btScalar mass = 1/fixation->getRigidBody()->getInvMass();
- impulseX = new BrainOut(outs["impulseX"]);
+ impulseX = new BrainOut(outs["impulseX"].toObject());
impulseX->setMin(-mass*MASS_FACTOR);
impulseX->setMin(mass*MASS_FACTOR);
- impulseY = new BrainOut(outs["impulseY"]);
+ impulseY = new BrainOut(outs["impulseY"].toObject());
impulseY->setMin(-mass*MASS_FACTOR*10.0);
impulseY->setMin(mass*MASS_FACTOR*10.0);
- impulseZ = new BrainOut(outs["impulseZ"]);
+ impulseZ = new BrainOut(outs["impulseZ"].toObject());
impulseZ->setMin(-mass*MASS_FACTOR);
impulseZ->setMin(mass*MASS_FACTOR);
@@ -71,11 +71,11 @@ void FlyingEffector::step() {
fixation->getRigidBody()->applyCentralImpulse(impulse);
}
-QVariant FlyingEffector::serialize() {
+QJsonObject FlyingEffector::serialize() {
- QVariantMap data = Effector::serialize().toMap();
+ QJsonObject data = Effector::serialize();
- QVariantMap bOuts;
+ QJsonObject bOuts;
bOuts.insert("impulseX", impulseX->serialize());
bOuts.insert("impulseY", impulseY->serialize());
bOuts.insert("impulseZ", impulseZ->serialize());
@@ -84,16 +84,16 @@ QVariant FlyingEffector::serialize() {
return data;
}
-QVariant FlyingEffector::generateEmpty()
+QJsonObject FlyingEffector::generateEmpty()
{
- QVariantMap data = Effector::generateEmpty(TYPE_NAME, TYPE).toMap();
+ QJsonObject data = Effector::generateEmpty(TYPE_NAME, TYPE);
// min & max init in contructor according mass of fixation
BrainOut impulseX(0,0);
BrainOut impulseY(0,0);
BrainOut impulseZ(0,0);
- QVariantMap bOuts;
+ QJsonObject bOuts;
bOuts.insert("impulseX", impulseX.serialize());
bOuts.insert("impulseY", impulseY.serialize());
bOuts.insert("impulseZ", impulseZ.serialize());
diff --git a/src/genecraft/core/entities/effectors/flyingeffector.h b/src/genecraft/core/entities/effectors/flyingeffector.h
index cb62ff8..47a0e34 100644
--- a/src/genecraft/core/entities/effectors/flyingeffector.h
+++ b/src/genecraft/core/entities/effectors/flyingeffector.h
@@ -35,16 +35,16 @@ class FlyingEffector : public Effector
FlyingEffector(Fixation *fixation);
// To create from data
- FlyingEffector(QVariant data, Fixation *fixation);
+ FlyingEffector(QJsonObject data, Fixation *fixation);
// To create empty effector serialization data
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// To update world.
void step();
// To serialize
- QVariant serialize();
+ QJsonObject serialize();
private:
diff --git a/src/genecraft/core/entities/effectors/grippereffector.cpp b/src/genecraft/core/entities/effectors/grippereffector.cpp
index 97a631a..1420103 100644
--- a/src/genecraft/core/entities/effectors/grippereffector.cpp
+++ b/src/genecraft/core/entities/effectors/grippereffector.cpp
@@ -42,7 +42,7 @@ GripperEffector::GripperEffector(Fixation *fixation) : Effector(TYPE_NAME, TYPE)
}
// To create from serialization data
-GripperEffector::GripperEffector(QVariant data, Fixation * fixation) :
+GripperEffector::GripperEffector(QJsonObject data, Fixation * fixation) :
Effector(data), fixation(fixation) {
// create the air contraint
@@ -50,7 +50,7 @@ GripperEffector::GripperEffector(QVariant data, Fixation * fixation) :
constraint->setEnabled(false);
fixation->getShapesFactory()->getWorld()->getBulletWorld()->addConstraint(constraint);
- gripperOutput = new BrainOut(data.toMap()["gripperOutput"]);
+ gripperOutput = new BrainOut(data["gripperOutput"].toObject());
brainOutputs.append(gripperOutput);
}
@@ -62,8 +62,8 @@ GripperEffector::~GripperEffector()
}
// To serialize
-QVariant GripperEffector::serialize() {
- QVariantMap data = Effector::serialize().toMap();
+QJsonObject GripperEffector::serialize() {
+ QJsonObject data = Effector::serialize();
data.insert("gripperOutput", gripperOutput->serialize());
return data;
}
@@ -91,9 +91,9 @@ void GripperEffector::step() {
constraint->setEnabled(false);
}
-QVariant GripperEffector::generateEmpty()
+QJsonObject GripperEffector::generateEmpty()
{
- QVariantMap data = Effector::generateEmpty(TYPE_NAME, TYPE).toMap();
+ QJsonObject data = Effector::generateEmpty(TYPE_NAME, TYPE);
BrainOut gripperOutput(-1,1);
data.insert("gripperOutput", gripperOutput.serialize());
diff --git a/src/genecraft/core/entities/effectors/grippereffector.h b/src/genecraft/core/entities/effectors/grippereffector.h
index 40c43bd..01a5798 100644
--- a/src/genecraft/core/entities/effectors/grippereffector.h
+++ b/src/genecraft/core/entities/effectors/grippereffector.h
@@ -33,16 +33,16 @@ class GripperEffector : public Effector
GripperEffector(Fixation *fixation);
// To create from serialization data
- GripperEffector(QVariant data, Fixation * fixation);
+ GripperEffector(QJsonObject data, Fixation * fixation);
// To create empty effector serialization data
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// Destructor
~GripperEffector();
// To serialize
- QVariant serialize();
+ QJsonObject serialize();
// To update world.
void step();
diff --git a/src/genecraft/core/entities/effectors/rotationalmotorseffector.cpp b/src/genecraft/core/entities/effectors/rotationalmotorseffector.cpp
index acdb20e..5d7ce76 100644
--- a/src/genecraft/core/entities/effectors/rotationalmotorseffector.cpp
+++ b/src/genecraft/core/entities/effectors/rotationalmotorseffector.cpp
@@ -22,10 +22,9 @@ along with Genecraft-Project. If not, see .
#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"
#include
-#include
+#include
#include
-#include
-#include
+#include
#include "tools.h"
#include "brain/sinusin.h"
#include "brain/brainout.h"
@@ -66,11 +65,11 @@ RotationalMotorsEffector::RotationalMotorsEffector(Bone * bone, btGeneric6DofCon
}
-RotationalMotorsEffector::RotationalMotorsEffector(QVariant data, Bone *bone, btGeneric6DofConstraint* ct) : Effector(data),
+RotationalMotorsEffector::RotationalMotorsEffector(QJsonObject data, Bone *bone, btGeneric6DofConstraint* ct) : Effector(data),
constraint(ct), m_isDisable(false), outputsFrom(0 /*RotationalMotorsModifier::OUTPUTS_FROM_NORMAL_POSITION*/)
{
this->bone = bone;
- QVariantMap motorsMap = data.toMap()["outs"].toMap();
+ QJsonObject motorsMap = data["outs"].toObject();
QString motors[] = {"x","y","z"};
@@ -82,7 +81,7 @@ RotationalMotorsEffector::RotationalMotorsEffector(QVariant data, Bone *bone, bt
QString motor = motors[i];
if(motorsMap.contains(motor)) {
- brainMotorOutputs[i] = new BrainOutMotor(motorsMap.value(motor), constraint->getRotationalLimitMotor(i));
+ brainMotorOutputs[i] = new BrainOutMotor(motorsMap.value(motor).toObject(), constraint->getRotationalLimitMotor(i));
brainMotorOutputs[i]->motor->m_enableMotor = true;
brainMotorOutputs[i]->motor->m_currentPosition = 0;
this->outputsFrom = 1;
@@ -144,9 +143,9 @@ void RotationalMotorsEffector::disconnectMotor(int i)
}
}
-QVariant RotationalMotorsEffector::serialize() {
- QVariantMap data = Effector::serialize().toMap();
- QVariantMap bOuts;
+QJsonObject RotationalMotorsEffector::serialize() {
+ QJsonObject data = Effector::serialize();
+ QJsonObject bOuts;
QString motors[] = {"x","y","z"};
for(int i = 0; i < 3; i++)
if(brainMotorOutputs[i]) {
diff --git a/src/genecraft/core/entities/effectors/rotationalmotorseffector.h b/src/genecraft/core/entities/effectors/rotationalmotorseffector.h
index 1bded08..9b86116 100644
--- a/src/genecraft/core/entities/effectors/rotationalmotorseffector.h
+++ b/src/genecraft/core/entities/effectors/rotationalmotorseffector.h
@@ -21,6 +21,7 @@ along with Genecraft-Project. If not, see .
#define ROTATIONALMOTORS_H
#include
+#include
#include "genecraftcoreclasses.h"
#include "effector.h"
#include "brainoutmotor.h"
@@ -45,7 +46,7 @@ class RotationalMotorsEffector : public Effector
public:
RotationalMotorsEffector(Bone * bone, btGeneric6DofConstraint * constraint);
- RotationalMotorsEffector(QVariant data, Bone * bone, btGeneric6DofConstraint* ct);
+ RotationalMotorsEffector(QJsonObject data, Bone * bone, btGeneric6DofConstraint* ct);
~RotationalMotorsEffector();
// To connect to brain
@@ -66,7 +67,7 @@ class RotationalMotorsEffector : public Effector
BrainOutMotor *getBrainOutputs(int i) { return brainMotorOutputs[i]; }
// To get a seralised representation of effector
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
// static const int OUTPUTS_FROM_NORMAL_POSITION;
// static const int OUTPUTS_FROM_BRAIN;
diff --git a/src/genecraft/core/entities/entity.cpp b/src/genecraft/core/entities/entity.cpp
index 4888bf3..6d254e0 100644
--- a/src/genecraft/core/entities/entity.cpp
+++ b/src/genecraft/core/entities/entity.cpp
@@ -96,9 +96,9 @@ void Entity::setShape(TreeShape* shape) {
this->treeShape->getRoot()->setEntity(this);
}
-QVariant Entity::serializeOrigins()
+QJsonObject Entity::serializeOrigins()
{
- QVariantMap origins;
+ QJsonObject origins;
origins.insert("name",name);
origins.insert("family",family);
@@ -107,9 +107,9 @@ QVariant Entity::serializeOrigins()
return origins;
}
-QVariant Entity::serialize()
+QJsonObject Entity::serialize()
{
- QVariantMap entityVariant;
+ QJsonObject entityVariant;
entityVariant.insert("version", genomeVersion);
entityVariant.insert("type", type);
@@ -156,7 +156,7 @@ void Entity::addLinkToEffector(Effector *modifier) {
// Creatures from creature viewer
if(modifier->getOutputs()[i]->getConnexionInfo() == "") {
QString randomFunc = brain->createRandomFunc(2);
- modifier->getOutputs()[i]->setConnexionInfo(QVariant(randomFunc));
+ modifier->getOutputs()[i]->setConnexionInfo(randomFunc);
}
brain->addOut(modifier->getOutputs()[i]);
@@ -172,7 +172,7 @@ void Entity::addBrainOut(BrainOut *brainOut)
if(brainOut->getConnexionInfo() == "") {
QString randomFunc = brain->createRandomFunc(2);
- brainOut->setConnexionInfo(QVariant(randomFunc));
+ brainOut->setConnexionInfo(randomFunc);
}
brain->addOut(brainOut);
diff --git a/src/genecraft/core/entities/entity.h b/src/genecraft/core/entities/entity.h
index 6059fba..5288235 100644
--- a/src/genecraft/core/entities/entity.h
+++ b/src/genecraft/core/entities/entity.h
@@ -21,6 +21,7 @@ along with Genecraft-Project. If not, see .
#define ENTITY_H
#include
+#include
#include "genecraftcoreclasses.h"
#include "statistics/statisticsstorage.h"
#include "body/fixation.h"
@@ -90,8 +91,8 @@ class Entity : public QObject
//static EntityPropertiesController *getInspectorWidget(Entity * selectedEntity = NULL, btRigidBody *selectedBody = NULL);
// serialisation
- QVariant serialize();
- QVariant serializeOrigins();
+ QJsonObject serialize();
+ QJsonObject serializeOrigins();
// Set ressource
void setRessource(Ressource* r);
diff --git a/src/genecraft/core/entities/entityfamily.h b/src/genecraft/core/entities/entityfamily.h
index 60d3ac1..624548f 100644
--- a/src/genecraft/core/entities/entityfamily.h
+++ b/src/genecraft/core/entities/entityfamily.h
@@ -43,7 +43,7 @@ class EntityFamily : public QObject
virtual Entity* createEntity(btShapesFactory *shapesFactory, const btVector3 &position) = 0;
- virtual QVariant serialize() = 0;
+ virtual QJsonObject serialize() = 0;
};
}
diff --git a/src/genecraft/core/entities/families/antfamily.cpp b/src/genecraft/core/entities/families/antfamily.cpp
index 40d0569..b067792 100644
--- a/src/genecraft/core/entities/families/antfamily.cpp
+++ b/src/genecraft/core/entities/families/antfamily.cpp
@@ -122,7 +122,7 @@ void AntFamily::addLeg(Fixation *fixBody, btScalar yAxis, btScalar zAxis, const
}
}
-QVariant AntFamily::serialize() {
- return QVariant(); // TODO
+QJsonObject AntFamily::serialize() {
+ return QJsonObject(); // TODO
}
}
diff --git a/src/genecraft/core/entities/families/antfamily.h b/src/genecraft/core/entities/families/antfamily.h
index b5195bb..c30ce7a 100644
--- a/src/genecraft/core/entities/families/antfamily.h
+++ b/src/genecraft/core/entities/families/antfamily.h
@@ -48,7 +48,7 @@ class AntFamily : public EntityFamily
const btVector3 &position);
// To serialize the family
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
protected:
diff --git a/src/genecraft/core/entities/families/caterpillarfamily.cpp b/src/genecraft/core/entities/families/caterpillarfamily.cpp
index 9df912c..110de07 100644
--- a/src/genecraft/core/entities/families/caterpillarfamily.cpp
+++ b/src/genecraft/core/entities/families/caterpillarfamily.cpp
@@ -22,7 +22,7 @@ along with Genecraft-Project. If not, see .
#include "body/treeshape.h"
#include "body/fixation.h"
#include "body/bone.h"
-#include
+#include
#include
#include "tools.h"
#include "sensors/accelerometersensor.h"
@@ -49,13 +49,13 @@ namespace GeneCraftCore {
this->antennaRadius = Tools::random(.1,0.1);
}
- CaterpillarFamily::CaterpillarFamily(QVariant data, QObject *parent) :
+ CaterpillarFamily::CaterpillarFamily(QJsonObject data, QObject *parent) :
EntityFamily(parent)
{
- this->length = data.toMap()["length"].toInt();
+ this->length = data["length"].toInt();
- this->pieceLength = data.toMap()["piecelength"].toFloat();
- this->pieceRadius = data.toMap()["pieceRadius"].toFloat();
+ this->pieceLength = data["piecelength"].toDouble();
+ this->pieceRadius = data["pieceRadius"].toDouble();
}
Entity* CaterpillarFamily::createEntity(btShapesFactory* factory, const btVector3 &position) {
@@ -165,11 +165,11 @@ namespace GeneCraftCore {
return entity;
}
- QVariant CaterpillarFamily::serialize() {
- QVariantMap data;
- data["length"] = QVariant(length);
- data["piecelength"] = QVariant(pieceLength);
- data["pieceRadius"] = QVariant(pieceRadius);
+ QJsonObject CaterpillarFamily::serialize() {
+ QJsonObject data;
+ data["length"] = length;
+ data["piecelength"] = pieceLength;
+ data["pieceRadius"] = pieceRadius;
return data;
}
}
diff --git a/src/genecraft/core/entities/families/caterpillarfamily.h b/src/genecraft/core/entities/families/caterpillarfamily.h
index c3134a9..09ded20 100644
--- a/src/genecraft/core/entities/families/caterpillarfamily.h
+++ b/src/genecraft/core/entities/families/caterpillarfamily.h
@@ -45,14 +45,14 @@ class CaterpillarFamily : public EntityFamily
explicit CaterpillarFamily(QObject *parent = 0);
// To create the family from serialization data
- CaterpillarFamily(QVariant data, QObject *parent = 0);
+ CaterpillarFamily(QJsonObject data, QObject *parent = 0);
// To create an entity of this family
Entity* createEntity(btShapesFactory* factory, const btVector3 &positionSensor);
// To serialize family
- QVariant serialize();
- void load(QVariant data);
+ QJsonObject serialize();
+ void load(QJsonObject data);
private:
int length;
diff --git a/src/genecraft/core/entities/families/genericfamily.cpp b/src/genecraft/core/entities/families/genericfamily.cpp
index 699381f..d321cb7 100644
--- a/src/genecraft/core/entities/families/genericfamily.cpp
+++ b/src/genecraft/core/entities/families/genericfamily.cpp
@@ -40,28 +40,29 @@ along with Genecraft-Project. If not, see .
#include "effectors/grippereffector.h"
#include "effectors/rotationalmotorseffector.h"
+#include
+
namespace GeneCraftCore {
GenericFamily::GenericFamily()
{
}
-Entity *GenericFamily::createEntity(QVariant genotype,
+Entity *GenericFamily::createEntity(QJsonObject genotype,
btShapesFactory *shapesFactory,
const btVector3 &initialPosition)
{
- QVariantMap entityMap = genotype.toMap();
// Entity & origins
- QVariantMap origins = entityMap.value("origins").toMap();
+ QJsonObject origins = genotype.value("origins").toObject();
Entity * entity = new Entity(origins.value("name").toString(),
origins.value("family").toString(),
"generic",
origins.value("generation").toInt());
// Brain
- entity->setBrain(new BrainFunctional(entityMap.value("brain")));
+ entity->setBrain(new BrainFunctional(genotype.value("brain").toObject()));
// Body
- QVariantMap body = entityMap.value("body").toMap();
+ QJsonObject body = genotype.value("body").toObject();
if(body.value("shapeType").toString().compare(QString("TreeShape")) == 0)
{
TreeShape* treeShape = new TreeShape(shapesFactory);
@@ -70,10 +71,10 @@ Entity *GenericFamily::createEntity(QVariant genotype,
initTransform.setIdentity();
initTransform.setOrigin(initialPosition);
- Fixation* root = GenericFamily::createRootFromGenotype(shapesFactory, body.value("shape"), initTransform);
+ Fixation* root = GenericFamily::createRootFromGenotype(shapesFactory, body.value("shape").toObject(), initTransform);
treeShape->setRoot(root);
entity->setShape(treeShape);
- GenericFamily::buildFixFromGenotype(shapesFactory, root, root,body.value("shape").toMap().value("rootFix"));
+ GenericFamily::buildFixFromGenotype(shapesFactory, root, root,body.value("shape").toObject().value("rootFix").toObject());
}
@@ -100,53 +101,52 @@ Entity *GenericFamily::createVirginEntity(btShapesFactory *shapesFactory,
return entity;
}
-Fixation* GenericFamily::createRootFromGenotype(btShapesFactory *shapesFactory, QVariant genotype, btTransform initTransform) {
- QVariantMap treeShapeMap = genotype.toMap();
+Fixation* GenericFamily::createRootFromGenotype(btShapesFactory *shapesFactory, QJsonObject genotype, btTransform initTransform) {
// Root fix
- QVariantMap rootFixMap = treeShapeMap.value("rootFix").toMap();
+ QJsonObject rootFixMap = genotype.value("rootFix").toObject();
return new Fixation(shapesFactory, rootFixMap.value("radius").toDouble(), initTransform);
}
-void GenericFamily::buildFixFromGenotype(btShapesFactory *shapesFactory, Fixation *fix, Fixation* root, QVariant fixGenotype)
+void GenericFamily::buildFixFromGenotype(btShapesFactory *shapesFactory, Fixation *fix, Fixation* root, QJsonObject fixGenotype)
{
// -------------
// -- sensors --
// -------------
- foreach(QVariant sensorData, fixGenotype.toMap()["sensors"].toList()) {
- QVariantMap sensorMap = sensorData.toMap();
+ foreach(QJsonValue sensorData, fixGenotype["sensors"].toArray()) {
+ QJsonObject sensorMap = sensorData.toObject();
switch((SensorType)sensorMap["type"].toInt()) {
case accelerometerSensor: {
- fix->addSensor(new AccelerometerSensor(sensorData, fix));
+ fix->addSensor(new AccelerometerSensor(sensorData.toObject(), fix));
}
break;
case gyroscopicSensor: {
- fix->addSensor(new GyroscopicSensor(sensorData, fix));
+ fix->addSensor(new GyroscopicSensor(sensorData.toObject(), fix));
}
break;
case positionSensor:{
- fix->addSensor(new PositionSensor(sensorData, root, fix));
+ fix->addSensor(new PositionSensor(sensorData.toObject(), root, fix));
}
break;
case contactSensor:{
- fix->addSensor(new ContactSensor(sensorData, fix));
+ fix->addSensor(new ContactSensor(sensorData.toObject(), fix));
}
break;
case boxSmellSensor:{
- fix->addSensor(new BoxSmellSensor(sensorData, fix));
+ fix->addSensor(new BoxSmellSensor(sensorData.toObject(), fix));
break;
}
case distanceSensor:{
- fix->addSensor(new DistanceSensor(sensorData, fix));
+ fix->addSensor(new DistanceSensor(sensorData.toObject(), fix));
}
break;
}
@@ -155,8 +155,8 @@ void GenericFamily::buildFixFromGenotype(btShapesFactory *shapesFactory, Fixatio
// --------------
// -- effector --
// --------------
- foreach(QVariant effector, fixGenotype.toMap()["effectors"].toList()) {
- QVariantMap effectorMap = effector.toMap();
+ foreach(QJsonValue effector, fixGenotype["effectors"].toArray()) {
+ QJsonObject effectorMap = effector.toObject();
switch((EffectorType)effectorMap["type"].toInt()) {
case rotationalMotorEffector: break;
@@ -174,27 +174,27 @@ void GenericFamily::buildFixFromGenotype(btShapesFactory *shapesFactory, Fixatio
// -----------
// -- bones --
// -----------
- QVariantList bonesVariantList = fixGenotype.toMap().value("bones").toList();
+ QJsonArray bonesVariantList = fixGenotype.value("bones").toArray();
- foreach(QVariant bone, bonesVariantList)
+ foreach(QJsonValue bone, bonesVariantList)
{
- QVariantMap boneMap = bone.toMap();
+ QJsonObject boneMap = bone.toObject();
// Radius & lenght
btScalar boneRadius = boneMap.value("radius").toDouble();
btScalar boneLength = boneMap.value("length").toDouble();
- btScalar endFixRadius = boneMap.value("endFix").toMap().value("radius").toDouble();
+ btScalar endFixRadius = boneMap.value("endFix").toObject().value("radius").toDouble();
// Yaw & Roll (local)
- QVariantMap localRotationMap = boneMap.value("localRotation").toMap();
+ QJsonObject localRotationMap = boneMap.value("localRotation").toObject();
btScalar yAxisRot = localRotationMap.value("y").toDouble();
btScalar zAxisRot = localRotationMap.value("z").toDouble();
// Limits
btVector3 lowerLimits, upperLimits;
- QVariantMap lowerLimitsMap = boneMap.value("lowerLimits").toMap();
- QVariantMap upperLimitsMap = boneMap.value("upperLimits").toMap();
+ QJsonObject lowerLimitsMap = boneMap.value("lowerLimits").toObject();
+ QJsonObject upperLimitsMap = boneMap.value("upperLimits").toObject();
lowerLimits.setValue(lowerLimitsMap.value("x").toDouble(),
lowerLimitsMap.value("y").toDouble(),
@@ -203,10 +203,10 @@ void GenericFamily::buildFixFromGenotype(btShapesFactory *shapesFactory, Fixatio
upperLimitsMap.value("y").toDouble(),
upperLimitsMap.value("z").toDouble());
- Bone *bone = fix->addBone(yAxisRot,zAxisRot,boneRadius,boneLength,endFixRadius,lowerLimits,upperLimits);
- bone->setMotorModifierData(boneMap["muscle"]);
+ Bone *b = fix->addBone(yAxisRot,zAxisRot,boneRadius,boneLength,endFixRadius,lowerLimits,upperLimits);
+ b->setMotorModifierData(boneMap["muscle"].toObject());
// Add bone recurcively
- GenericFamily::buildFixFromGenotype(shapesFactory, bone->getEndFixation(), root, boneMap.value("endFix"));
+ GenericFamily::buildFixFromGenotype(shapesFactory, b->getEndFixation(), root, boneMap.value("endFix").toObject());
}
}
}
diff --git a/src/genecraft/core/entities/families/genericfamily.h b/src/genecraft/core/entities/families/genericfamily.h
index 6cce58e..f0349f7 100644
--- a/src/genecraft/core/entities/families/genericfamily.h
+++ b/src/genecraft/core/entities/families/genericfamily.h
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef GENERICFAMILY_H
#define GENERICFAMILY_H
-#include
+#include
#include "genecraftcoreclasses.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btTransform.h"
@@ -43,7 +43,7 @@ class GenericFamily
GenericFamily();
// To create an entity with its genome
- static Entity *createEntity(QVariant genotype,
+ static Entity *createEntity(QJsonObject genotype,
btShapesFactory *shapesFactory,
const btVector3 &initialPosition);
@@ -53,8 +53,8 @@ class GenericFamily
const btVector3 &initialPosition);
- static Fixation* createRootFromGenotype(btShapesFactory *shapesFactory, QVariant genotype, btTransform initTransform);
- static void buildFixFromGenotype(btShapesFactory *shapesFactory, Fixation *fix, Fixation* root, QVariant fixGenotype);
+ static Fixation* createRootFromGenotype(btShapesFactory *shapesFactory, QJsonObject genotype, btTransform initTransform);
+ static void buildFixFromGenotype(btShapesFactory *shapesFactory, Fixation *fix, Fixation* root, QJsonObject fixGenotype);
};
diff --git a/src/genecraft/core/entities/families/snakefamily.cpp b/src/genecraft/core/entities/families/snakefamily.cpp
index 2ec5224..207128b 100644
--- a/src/genecraft/core/entities/families/snakefamily.cpp
+++ b/src/genecraft/core/entities/families/snakefamily.cpp
@@ -21,7 +21,7 @@ along with Genecraft-Project. If not, see .
#include "body/treeshape.h"
#include "body/fixation.h"
#include "body/bone.h"
-#include
+#include
#include
#include "tools.h"
#include "sensors/accelerometersensor.h"
@@ -39,13 +39,13 @@ namespace GeneCraftCore {
this->fixRadius = Tools::random(0.1,1.0);
}
- SnakeFamily::SnakeFamily(QVariant data, QObject *parent) :
+ SnakeFamily::SnakeFamily(QJsonObject data, QObject *parent) :
EntityFamily(parent)
{
- this->length = data.toMap()["length"].toInt();
+ this->length = data["length"].toInt();
- this->pieceLength = data.toMap()["piecelength"].toFloat();
- this->pieceRadius = data.toMap()["pieceRadius"].toFloat();
+ this->pieceLength = data["piecelength"].toDouble();
+ this->pieceRadius = data["pieceRadius"].toDouble();
}
Entity* SnakeFamily::createEntity(btShapesFactory* factory, const btVector3 &position) {
@@ -145,11 +145,11 @@ namespace GeneCraftCore {
return entity;
}
- QVariant SnakeFamily::serialize() {
- QVariantMap data;
- data["length"] = QVariant(length);
- data["piecelength"] = QVariant(pieceLength);
- data["pieceRadius"] = QVariant(pieceRadius);
+ QJsonObject SnakeFamily::serialize() {
+ QJsonObject data;
+ data["length"] = length;
+ data["piecelength"] = pieceLength;
+ data["pieceRadius"] = pieceRadius;
return data;
}
}
diff --git a/src/genecraft/core/entities/families/snakefamily.h b/src/genecraft/core/entities/families/snakefamily.h
index a4081c1..7e63a4b 100644
--- a/src/genecraft/core/entities/families/snakefamily.h
+++ b/src/genecraft/core/entities/families/snakefamily.h
@@ -45,14 +45,14 @@ class SnakeFamily : public EntityFamily
explicit SnakeFamily(QObject *parent = 0);
// To create the family from serialization data
- SnakeFamily(QVariant data, QObject *parent = 0);
+ SnakeFamily(QJsonObject data, QObject *parent = 0);
// To create an entity of this family
Entity* createEntity(btShapesFactory* factory, const btVector3 &positionSensor);
// To serialize family
- QVariant serialize();
- void load(QVariant data);
+ QJsonObject serialize();
+ void load(QJsonObject data);
private:
int length;
diff --git a/src/genecraft/core/entities/families/spiderfamily.cpp b/src/genecraft/core/entities/families/spiderfamily.cpp
index ab47fc7..eaa50ae 100644
--- a/src/genecraft/core/entities/families/spiderfamily.cpp
+++ b/src/genecraft/core/entities/families/spiderfamily.cpp
@@ -126,8 +126,8 @@ void SpiderFamily::addLeg(Fixation *fixBody, btScalar yAxis, btScalar zAxis, con
}
}
-QVariant SpiderFamily::serialize() {
- return QVariant();
+QJsonObject SpiderFamily::serialize() {
+ return QJsonObject();
}
}
diff --git a/src/genecraft/core/entities/families/spiderfamily.h b/src/genecraft/core/entities/families/spiderfamily.h
index c257d24..d8728a9 100644
--- a/src/genecraft/core/entities/families/spiderfamily.h
+++ b/src/genecraft/core/entities/families/spiderfamily.h
@@ -48,7 +48,7 @@ class SpiderFamily : public EntityFamily
virtual Entity* createEntity(btShapesFactory *shapesFactory,
const btVector3 &position);
// To serialize the family
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
protected:
diff --git a/src/genecraft/core/entities/mutation/bonelimitsmutation.cpp b/src/genecraft/core/entities/mutation/bonelimitsmutation.cpp
index 25ea8eb..7410b22 100644
--- a/src/genecraft/core/entities/mutation/bonelimitsmutation.cpp
+++ b/src/genecraft/core/entities/mutation/bonelimitsmutation.cpp
@@ -35,7 +35,7 @@ BoneLimitsMutation::BoneLimitsMutation()
axisMutation->maxValue = SIMD_PI;
}
-void BoneLimitsMutation::mutate(QVariantMap &lowerLimits, QVariantMap &upperLimits)
+void BoneLimitsMutation::mutate(QJsonObject &lowerLimits, QJsonObject &upperLimits)
{
// foreach axis...
QString allAxis[] = {"x","y","z"};
@@ -66,8 +66,8 @@ void BoneLimitsMutation::mutate(QVariantMap &lowerLimits, QVariantMap &upperLimi
lowerLimits.remove(axis);
upperLimits.remove(axis);
- lowerLimits.insert(axis,QVariant((double)loValue));
- upperLimits.insert(axis,QVariant((double)upValue));
+ lowerLimits.insert(axis,(double)loValue);
+ upperLimits.insert(axis,(double)upValue);
}
}
diff --git a/src/genecraft/core/entities/mutation/bonelimitsmutation.h b/src/genecraft/core/entities/mutation/bonelimitsmutation.h
index cbd0d4d..7b85ad1 100644
--- a/src/genecraft/core/entities/mutation/bonelimitsmutation.h
+++ b/src/genecraft/core/entities/mutation/bonelimitsmutation.h
@@ -32,10 +32,10 @@ class BoneLimitsMutation : public Mutation
BoneLimitsMutation();
// Not used !
- void mutate(QVariantMap &, QString){}
+ void mutate(QJsonObject &, QString){}
// To mutate, a lower limit can't be upper than an upper limit !
- void mutate(QVariantMap &lowerLimits, QVariantMap &upperLimits);
+ void mutate(QJsonObject &lowerLimits, QJsonObject &upperLimits);
FloatMutation *axisMutation;
diff --git a/src/genecraft/core/entities/mutation/brainnodemutation.h b/src/genecraft/core/entities/mutation/brainnodemutation.h
index 673aa79..b764e34 100644
--- a/src/genecraft/core/entities/mutation/brainnodemutation.h
+++ b/src/genecraft/core/entities/mutation/brainnodemutation.h
@@ -26,7 +26,7 @@ namespace GeneCraftCore {
class BrainNodeMutation : public Mutation {
public:
- void mutate(QVariantMap &map, QString key);
+ void mutate(QJsonObject &map, QString key);
btScalar minFact;
btScalar maxFact;
btScalar minValue;
diff --git a/src/genecraft/core/entities/mutation/crossovermanager.cpp b/src/genecraft/core/entities/mutation/crossovermanager.cpp
index 1d7b878..efdb0fe 100644
--- a/src/genecraft/core/entities/mutation/crossovermanager.cpp
+++ b/src/genecraft/core/entities/mutation/crossovermanager.cpp
@@ -25,29 +25,23 @@ namespace GeneCraftCore {
{
}
-
- QVariant CrossoverManager::onePointCross(QVariant a, QVariant b) {
- QVariantMap entityA = a.toMap();
- QVariantMap entityB = b.toMap();
- QVariantMap resultEntity;
+ // TODO Implementation
+ QJsonObject CrossoverManager::onePointCross(QJsonObject a, QJsonObject b) {
+ QJsonObject resultEntity;
return resultEntity;
}
- QVariant CrossoverManager::twoPointCross(QVariant a, QVariant b) {
- QVariantMap entityA = a.toMap();
- QVariantMap entityB = b.toMap();
- QVariantMap resultEntity;
+ QJsonObject CrossoverManager::twoPointCross(QJsonObject a, QJsonObject b) {
+ QJsonObject resultEntity;
return resultEntity;
}
- QVariant CrossoverManager::uniformCross (QVariant a, QVariant b) {
- QVariantMap entityA = a.toMap();
- QVariantMap entityB = b.toMap();
- QVariantMap resultEntity;
+ QJsonObject CrossoverManager::uniformCross (QJsonObject a, QJsonObject b) {
+ QJsonObject resultEntity;
return resultEntity;
diff --git a/src/genecraft/core/entities/mutation/crossovermanager.h b/src/genecraft/core/entities/mutation/crossovermanager.h
index 8637fda..95ac510 100644
--- a/src/genecraft/core/entities/mutation/crossovermanager.h
+++ b/src/genecraft/core/entities/mutation/crossovermanager.h
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef CROSSOVERMANAGER_H
#define CROSSOVERMANAGER_H
-#include
+#include
namespace GeneCraftCore {
@@ -28,9 +28,9 @@ namespace GeneCraftCore {
{
public:
CrossoverManager();
- static QVariant onePointCross(QVariant a, QVariant b);
- static QVariant twoPointCross(QVariant a, QVariant b);
- static QVariant uniformCross (QVariant a, QVariant b);
+ static QJsonObject onePointCross(QJsonObject a, QJsonObject b);
+ static QJsonObject twoPointCross(QJsonObject a, QJsonObject b);
+ static QJsonObject uniformCross (QJsonObject a, QJsonObject b);
};
}
diff --git a/src/genecraft/core/entities/mutation/floatmutation.cpp b/src/genecraft/core/entities/mutation/floatmutation.cpp
index 53d0b3a..af851c1 100644
--- a/src/genecraft/core/entities/mutation/floatmutation.cpp
+++ b/src/genecraft/core/entities/mutation/floatmutation.cpp
@@ -20,16 +20,13 @@ along with Genecraft-Project. If not, see .
#include "floatmutation.h"
#include "tools.h"
-#include
-#include
+#include
#include
namespace GeneCraftCore {
- FloatMutation::FloatMutation(QVariant variant)
+ FloatMutation::FloatMutation(QJsonObject map)
{
- QVariantMap map = variant.toMap();
-
if(map["type"].toInt() == FloatMutationType) {
probability = map["probability"].toDouble();
if(map.contains("mean")) {
@@ -60,24 +57,24 @@ namespace GeneCraftCore {
enable = true;
}
- QVariant FloatMutation::serialize(){
+ QJsonObject FloatMutation::serialize(){
- QVariantMap map;
+ QJsonObject map;
- map.insert("type",QVariant(FloatMutationType));
- map.insert("probability",QVariant((double)probability));
- map.insert("mean",QVariant((double)mean));
- map.insert("sigma",QVariant((double)sigma));
- map.insert("minValue",QVariant((double)minValue));
- map.insert("maxValue",QVariant((double)maxValue));
- map.insert("enable",QVariant(enable));
+ map.insert("type", FloatMutationType);
+ map.insert("probability", (double)probability);
+ map.insert("mean", (double)mean);
+ map.insert("sigma", (double)sigma);
+ map.insert("minValue", (double)minValue);
+ map.insert("maxValue", (double)maxValue);
+ map.insert("enable", enable);
return map;
}
- void FloatMutation::mutate(QVariantMap &map, QString key){
+ void FloatMutation::mutate(QJsonObject &map, QString key){
- btScalar newValue = this->mutate((btScalar)map.value(key).toDouble());
+ btScalar newValue = this->mutate((btScalar)map[key].toDouble());
map.remove(key);
map.insert(key,(double)newValue);
diff --git a/src/genecraft/core/entities/mutation/floatmutation.h b/src/genecraft/core/entities/mutation/floatmutation.h
index 03b40b0..ab8eaef 100644
--- a/src/genecraft/core/entities/mutation/floatmutation.h
+++ b/src/genecraft/core/entities/mutation/floatmutation.h
@@ -28,10 +28,10 @@ namespace GeneCraftCore {
public:
FloatMutation();
- FloatMutation(QVariant variant);
- QVariant serialize();
+ FloatMutation(QJsonObject variant);
+ QJsonObject serialize();
- void mutate(QVariantMap &map, QString key);
+ void mutate(QJsonObject &map, QString key);
btScalar mutate(btScalar value);
btScalar mean;
btScalar sigma;
diff --git a/src/genecraft/core/entities/mutation/integermutation.cpp b/src/genecraft/core/entities/mutation/integermutation.cpp
index 5c844e0..e19b45a 100644
--- a/src/genecraft/core/entities/mutation/integermutation.cpp
+++ b/src/genecraft/core/entities/mutation/integermutation.cpp
@@ -24,9 +24,8 @@ along with Genecraft-Project. If not, see .
namespace GeneCraftCore {
- IntegerMutation::IntegerMutation(QVariant variant)
+ IntegerMutation::IntegerMutation(QJsonObject map)
{
- QVariantMap map = variant.toMap();
if(map["type"].toInt() == IntegerMutationType) {
probability = map["probability"].toDouble();
@@ -50,25 +49,25 @@ namespace GeneCraftCore {
enable = true;
}
- QVariant IntegerMutation::serialize(){
+ QJsonObject IntegerMutation::serialize(){
- QVariantMap map;
+ QJsonObject map;
- map.insert("type",QVariant(IntegerMutationType));
- map.insert("probability",QVariant((double)probability));
- map.insert("minIncr",QVariant((double)minIncr));
- map.insert("maxIncr",QVariant((double)maxIncr));
- map.insert("minValue",QVariant((double)minValue));
- map.insert("maxValue",QVariant((double)maxValue));
- map.insert("enable",QVariant(enable));
+ map.insert("type",IntegerMutationType);
+ map.insert("probability",(double)probability);
+ map.insert("minIncr",(double)minIncr);
+ map.insert("maxIncr",(double)maxIncr);
+ map.insert("minValue",(double)minValue);
+ map.insert("maxValue",(double)maxValue);
+ map.insert("enable",enable);
return map;
}
- void IntegerMutation::mutate(QVariantMap &map, QString key){
+ void IntegerMutation::mutate(QJsonObject &map, QString key){
int newValue = this->mutate(map.value(key).toInt());
map.remove(key);
- map.insert(key,QVariant((int)newValue));
+ map.insert(key,(int)newValue);
}
int IntegerMutation::mutate(int value) {
diff --git a/src/genecraft/core/entities/mutation/integermutation.h b/src/genecraft/core/entities/mutation/integermutation.h
index 2e09472..70f2eff 100644
--- a/src/genecraft/core/entities/mutation/integermutation.h
+++ b/src/genecraft/core/entities/mutation/integermutation.h
@@ -27,11 +27,11 @@ namespace GeneCraftCore {
class IntegerMutation : public Mutation {
public:
- IntegerMutation(QVariant variant);
+ IntegerMutation(QJsonObject variant);
IntegerMutation();
- QVariant serialize();
+ QJsonObject serialize();
- void mutate(QVariantMap &map, QString key);
+ void mutate(QJsonObject &map, QString key);
int mutate(int value);
int minIncr;
int maxIncr;
diff --git a/src/genecraft/core/entities/mutation/mutation.cpp b/src/genecraft/core/entities/mutation/mutation.cpp
index b083bff..fef8287 100644
--- a/src/genecraft/core/entities/mutation/mutation.cpp
+++ b/src/genecraft/core/entities/mutation/mutation.cpp
@@ -24,7 +24,7 @@ along with Genecraft-Project. If not, see .
namespace GeneCraftCore {
- void Mutation::mutate(QVariantMap &, QString){}
+ void Mutation::mutate(QJsonObject &, QString){}
bool Mutation::canMutate()
{
diff --git a/src/genecraft/core/entities/mutation/mutation.h b/src/genecraft/core/entities/mutation/mutation.h
index 8caed05..2b8c151 100644
--- a/src/genecraft/core/entities/mutation/mutation.h
+++ b/src/genecraft/core/entities/mutation/mutation.h
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef MUTATION_H
#define MUTATION_H
-#include
+#include
#include "LinearMath/btScalar.h"
namespace GeneCraftCore {
@@ -30,7 +30,7 @@ namespace GeneCraftCore {
class Mutation {
public:
btScalar probability;
- virtual void mutate(QVariantMap &map, QString key);
+ virtual void mutate(QJsonObject &map, QString key);
bool canMutate();
bool enable;
};
diff --git a/src/genecraft/core/entities/mutation/mutationsmanager.cpp b/src/genecraft/core/entities/mutation/mutationsmanager.cpp
index 9ea7503..40dce42 100644
--- a/src/genecraft/core/entities/mutation/mutationsmanager.cpp
+++ b/src/genecraft/core/entities/mutation/mutationsmanager.cpp
@@ -19,8 +19,8 @@ along with Genecraft-Project. If not, see .
#include "mutationsmanager.h"
-#include
-#include
+#include
+#include
#include "tools.h"
#include
#include
@@ -49,8 +49,6 @@ along with Genecraft-Project. If not, see .
#include "effectors/grippereffector.h"
#include "effectors/flyingeffector.h"
-#include "qxtjson.h"
-
namespace GeneCraftCore {
MutationsManager::MutationsManager()
@@ -213,28 +211,27 @@ namespace GeneCraftCore {
brainDistance->maxValue = 1.0;
}
- MutationsManager::MutationsManager(QVariant mutationsParams)
+ MutationsManager::MutationsManager(QJsonObject map)
{
- QVariantMap map = mutationsParams.toMap();
// --------------------
// -- BODY MUTATIONS --
// --------------------
- boneLength = new FloatMutation(map["boneLength"]);
- boneRadius = new FloatMutation(map["boneRadius"]);
- fixRadius = new FloatMutation(map["fixRadius"]);
- boneAngularOrigin = new FloatMutation(map["boneAngularOrigin"]);
+ boneLength = new FloatMutation(map["boneLength"].toObject());
+ boneRadius = new FloatMutation(map["boneRadius"].toObject());
+ fixRadius = new FloatMutation(map["fixRadius"].toObject());
+ boneAngularOrigin = new FloatMutation(map["boneAngularOrigin"].toObject());
boneAngularLimits = new BoneLimitsMutation();
delete boneAngularLimits->axisMutation;
- boneAngularLimits->axisMutation = new FloatMutation(map["boneAngularLimits"]);
+ boneAngularLimits->axisMutation = new FloatMutation(map["boneAngularLimits"].toObject());
// sensors
- sensorsStructural = new StructuralMutation(map["sensorsStructural"]);
- sensorsStructuralList = new StructuralList(map["sensorsStructuralList"]);
+ sensorsStructural = new StructuralMutation(map["sensorsStructural"].toObject());
+ sensorsStructuralList = new StructuralList(map["sensorsStructuralList"].toArray());
// effectors
- effectorsStructural = new StructuralMutation(map["effectorsStructural"]);
- effectorsStructuralList = new StructuralList(map["effectorsStructuralList"]);
+ effectorsStructural = new StructuralMutation(map["effectorsStructural"].toObject());
+ effectorsStructuralList = new StructuralList(map["effectorsStructuralList"].toArray());
// TODO serialize and add to ui
distanceSensorYZ = new FloatMutation();
@@ -245,21 +242,21 @@ namespace GeneCraftCore {
distanceSensorYZ->maxValue = SIMD_PI;
// bones
- bonesStructural = new StructuralMutation(map["bonesStructural"]);
+ bonesStructural = new StructuralMutation(map["bonesStructural"].toObject());
// ---------------------
// -- BRAIN MUTATIONS --
// ---------------------
// Plug grid size
- brainInPos = new FloatMutation(map["brainInPos"]);
- brainWeight = new FloatMutation(map["brainWeight"]);
- brainDistance = new FloatMutation(map["brainDistance"]);
- brainMemorySize = new IntegerMutation(map["brainMemorySize"]);
- brainFrequency = new IntegerMutation(map["brainFrequency"]);
- constValue = new FloatMutation(map["constValue"]);
- brainNodeList = new StructuralList(map["brainNodes"]);
- brainStructural = new StructuralMutation(map["brainStruct"]);
+ brainInPos = new FloatMutation(map["brainInPos"].toObject());
+ brainWeight = new FloatMutation(map["brainWeight"].toObject());
+ brainDistance = new FloatMutation(map["brainDistance"].toObject());
+ brainMemorySize = new IntegerMutation(map["brainMemorySize"].toObject());
+ brainFrequency = new IntegerMutation(map["brainFrequency"].toObject());
+ constValue = new FloatMutation(map["constValue"].toObject());
+ brainNodeList = new StructuralList(map["brainNodes"].toArray());
+ brainStructural = new StructuralMutation(map["brainStruct"].toObject());
if(brainNodeList->elements.size() < 22) {
qDebug() << "adding wave to the list of mutations !";
brainNodeList->elements.append(new MutationElement("wave : a", 22, 4));
@@ -299,9 +296,9 @@ namespace GeneCraftCore {
}
- QVariant MutationsManager::serialize(){
+ QJsonObject MutationsManager::serialize(){
- QVariantMap map;
+ QJsonObject map;
map.insert("boneLength",boneLength->serialize());
map.insert("boneRadius",boneRadius->serialize());
@@ -329,23 +326,23 @@ namespace GeneCraftCore {
return map;
}
- QVariant MutationsManager::mutateEntity(const QVariant &entityVariant) {
- QVariantMap entityMap = entityVariant.toMap();
- QVariantMap originsMap = entityMap["origins"].toMap();
- QVariantMap bodyMap = entityMap["body"].toMap();
- QVariantMap treeShapeMap = bodyMap["shape"].toMap();
- QVariantMap brainMap = entityMap["brain"].toMap();
+ QJsonObject MutationsManager::mutateEntity(const QJsonObject &map) {
+ QJsonObject entityMap = QJsonObject(map);
+ QJsonObject originsMap = entityMap["origins"].toObject();
+ QJsonObject bodyMap = entityMap["body"].toObject();
+ QJsonObject treeShapeMap = bodyMap["shape"].toObject();
+ QJsonObject brainMap = entityMap["brain"].toObject();
int generation = entityMap["generation"].toInt();
entityMap.insert("generation", generation+1);
// treeshape mutation
- QVariant newTreeShapeMap = this->mutateTreeShape(treeShapeMap);
+ QJsonObject newTreeShapeMap = this->mutateTreeShape(treeShapeMap);
bodyMap.remove("shape");
bodyMap.insert("shape", newTreeShapeMap);
entityMap.insert("body", bodyMap);
// brain mutation
- QVariant newBrainMap = this->mutateBrain(brainMap);
+ QJsonObject newBrainMap = this->mutateBrain(brainMap);
entityMap.remove("brain");
entityMap.insert("brain", newBrainMap);
@@ -357,20 +354,20 @@ namespace GeneCraftCore {
return entityMap;
}
- QVariant MutationsManager::mutateTreeShape(const QVariant &treeShapeVariant)
+ QJsonObject MutationsManager::mutateTreeShape(const QJsonObject &map)
{
- // Convert to map (IT'S NOW A COPY !)
- QVariantMap treeShapeMap = treeShapeVariant.toMap();
+ // clone
+ QJsonObject treeShapeMap = QJsonObject(map);
// mutate the root fix
- QVariant rootFixVariant = treeShapeMap.value("rootFix");
- rootFixVariant = mutateFixation(rootFixVariant);
+ QJsonObject rootFixMap = treeShapeMap.value("rootFix").toObject();
+ rootFixMap = mutateFixation(rootFixMap);
// mutate all bones
- QVariantMap rootFixMap = rootFixVariant.toMap(); // COPY !
- QVariantList newBonesList;
- foreach(QVariant boneVariant, rootFixMap.value("bones").toList()) {
- newBonesList.append(recursiveMutateTreeShape(boneVariant));
+ QJsonArray newBonesList;
+ foreach(QJsonValue boneVariant, rootFixMap.value("bones").toArray()) {
+ QJsonObject boneMap = boneVariant.toObject();
+ newBonesList.append(recursiveMutateTreeShape(boneMap));
}
// add new bone to fix
@@ -384,37 +381,35 @@ namespace GeneCraftCore {
return treeShapeMap;
}
- QVariant MutationsManager::recursiveMutateTreeShape(QVariant &boneVariant) {
+ QJsonObject MutationsManager::recursiveMutateTreeShape(QJsonObject &boneVariant) {
// mutate bone
boneVariant = mutateBone(boneVariant);
- QVariantMap boneVariantMap = boneVariant.toMap(); // COPY !
// mutate the end fix
- QVariant endFixVariant = boneVariantMap.value("endFix"); // COPY !
- endFixVariant = mutateFixation(endFixVariant);
+ QJsonObject endFixMap = boneVariant.value("endFix").toObject(); // COPY !
+ endFixMap = mutateFixation(endFixMap);
// mutate all bones
- QVariantMap endFixMap = endFixVariant.toMap(); // COPY !
- QVariantList newBonesList;
- foreach(QVariant boneVariant, endFixMap.value("bones").toList())
- newBonesList.append(recursiveMutateTreeShape(boneVariant));
-
+ QJsonArray newBonesList;
+ foreach(QJsonValue boneVariant, endFixMap.value("bones").toArray()) {
+ QJsonObject boneMap = boneVariant.toObject();
+ newBonesList.append(recursiveMutateTreeShape(boneMap));
+ }
// add new bone to fix
if(bonesStructural->checkAdd())
addBone(newBonesList);
endFixMap.remove("bones");
endFixMap.insert("bones",newBonesList);
- boneVariantMap.remove("endFix");
- boneVariantMap.insert("endFix",endFixMap);
+ boneVariant.remove("endFix");
+ boneVariant.insert("endFix",endFixMap);
- return boneVariantMap;
+ return boneVariant;
}
- QVariant MutationsManager::mutateBone(const QVariant &boneVariant){
- QVariantMap boneMap = boneVariant.toMap();
-
+ QJsonObject MutationsManager::mutateBone(const QJsonObject &map){
+ QJsonObject boneMap = QJsonObject(map);
// ----------
// -- size --
// ----------
@@ -428,7 +423,7 @@ namespace GeneCraftCore {
// --------------------
// -- angular origin --
// --------------------
- QVariantMap localRotation = boneMap["localRotation"].toMap();
+ QJsonObject localRotation = boneMap["localRotation"].toObject();
boneAngularOrigin->mutate(localRotation,"y");
boneAngularOrigin->mutate(localRotation,"z");
boneMap.remove("localRotation");
@@ -438,8 +433,8 @@ namespace GeneCraftCore {
// -- angular limits --
// --------------------
- QVariantMap lowerLimits = boneMap["lowerLimits"].toMap();
- QVariantMap upperLimits = boneMap["upperLimits"].toMap();
+ QJsonObject lowerLimits = boneMap["lowerLimits"].toObject();
+ QJsonObject upperLimits = boneMap["upperLimits"].toObject();
boneAngularLimits->mutate(lowerLimits,upperLimits);
@@ -451,9 +446,9 @@ namespace GeneCraftCore {
// ----------------------
// -- motors mutations --
// ----------------------
- QVariantMap newMuscle = boneMap["muscle"].toMap();
- QVariantMap newMotors;
- QVariantMap motors = newMuscle["outs"].toMap();
+ QJsonObject newMuscle = boneMap["muscle"].toObject();
+ QJsonObject newMotors;
+ QJsonObject motors = newMuscle["outs"].toObject();
QString allAxis[] = {"x","y","z"};
// foreach motor axis...
@@ -466,16 +461,16 @@ namespace GeneCraftCore {
if(motors.contains(motor))
{
// need to delete motor ?
- if(lowerLimits[motor].toFloat() == 0.0f && upperLimits[motor].toFloat() == 0.0f) {
+ if(lowerLimits[motor].toDouble() == 0.0f && upperLimits[motor].toDouble() == 0.0f) {
continue; // not insert in newMotors
}
- QVariantMap motorMap = motors[motor].toMap();
+ QJsonObject motorMap = motors[motor].toObject();
// new version
if(motorMap.contains("contractionOutput")) {
- QVariant newContraction = mutateBrainOut(motorMap["contractionOutput"]);
- QVariant newExpansion = mutateBrainOut(motorMap["expansionOutput"]);
+ QJsonObject newContraction = mutateBrainOut(motorMap["contractionOutput"].toObject());
+ QJsonObject newExpansion = mutateBrainOut(motorMap["expansionOutput"].toObject());
motorMap.remove("contractionOutput");
motorMap.remove("expansionOutput");
motorMap.insert("contractionOutput", newContraction);
@@ -487,10 +482,10 @@ namespace GeneCraftCore {
else {
// mutate all brainouts
- QVariantList brainOuts = motorMap["brainOuts"].toList();
+ QJsonArray brainOuts = motorMap["brainOuts"].toArray();
- QVariant newContraction = mutateBrainOut(brainOuts[0]);
- QVariant newExpansion = mutateBrainOut(brainOuts[1]);
+ QJsonObject newContraction = mutateBrainOut(brainOuts[0].toObject());
+ QJsonObject newExpansion = mutateBrainOut(brainOuts[1].toObject());
motorMap.insert("contractionOutput", newContraction);
motorMap.insert("expansionOutput", newExpansion);
motorMap.remove("brainOuts");
@@ -502,7 +497,7 @@ namespace GeneCraftCore {
} else {
// need to create a new motor ?
- if(lowerLimits[motor].toFloat() != 0.0f || upperLimits[motor].toFloat() != 0.0f) {
+ if(lowerLimits[motor].toDouble() != 0.0f || upperLimits[motor].toDouble() != 0.0f) {
newMotors.insert(motor,BrainOutMotor::generateEmpty());
}
}
@@ -516,18 +511,16 @@ namespace GeneCraftCore {
return boneMap;
}
- QVariant MutationsManager::mutateFixation(const QVariant &fixVariant){
-
- QVariantMap fixMap = fixVariant.toMap();
-
+ QJsonObject MutationsManager::mutateFixation(const QJsonObject &map){
+ QJsonObject fixMap = QJsonObject(map);
// radius mutation
fixRadius->mutate(fixMap, "radius");
// -----------------------
// -- Sensors mutations --
// -----------------------
- QVariantList sensorList = fixMap["sensors"].toList();
- QVariantList newSensorList;
+ QJsonArray sensorList = fixMap["sensors"].toArray();
+ QJsonArray newSensorList;
// remove / replace
int nbSensors = sensorList.count();
@@ -547,35 +540,35 @@ namespace GeneCraftCore {
}
// mutate sensor brain in
- foreach(QVariant sensor, sensorList) {
- QVariantMap sensorMap = sensor.toMap();
+ foreach(QJsonValue sensor, sensorList) {
+ QJsonObject sensorMap = sensor.toObject();
switch((SensorType) sensorMap["type"].toInt()) {
case accelerometerSensor:
- sensorMap.insert("inputX", mutateBrainIn(sensorMap["inputX"]));
- sensorMap.insert("inputY", mutateBrainIn(sensorMap["inputY"]));
- sensorMap.insert("inputZ", mutateBrainIn(sensorMap["inputZ"]));
+ sensorMap.insert("inputX", mutateBrainIn(sensorMap["inputX"].toObject()));
+ sensorMap.insert("inputY", mutateBrainIn(sensorMap["inputY"].toObject()));
+ sensorMap.insert("inputZ", mutateBrainIn(sensorMap["inputZ"].toObject()));
break;
case gyroscopicSensor:
- sensorMap.insert("inputPitch", mutateBrainIn(sensorMap["inputPitch"]));
- sensorMap.insert("inputYaw", mutateBrainIn(sensorMap["inputYaw"]));
- sensorMap.insert("inputRoll", mutateBrainIn(sensorMap["inputRoll"]));
+ sensorMap.insert("inputPitch", mutateBrainIn(sensorMap["inputPitch"].toObject()));
+ sensorMap.insert("inputYaw", mutateBrainIn(sensorMap["inputYaw"].toObject()));
+ sensorMap.insert("inputRoll", mutateBrainIn(sensorMap["inputRoll"].toObject()));
break;
case positionSensor:
- sensorMap.insert("inputX", mutateBrainIn(sensorMap["inputX"]));
- sensorMap.insert("inputY", mutateBrainIn(sensorMap["inputY"]));
- sensorMap.insert("inputZ", mutateBrainIn(sensorMap["inputZ"]));
+ sensorMap.insert("inputX", mutateBrainIn(sensorMap["inputX"].toObject()));
+ sensorMap.insert("inputY", mutateBrainIn(sensorMap["inputY"].toObject()));
+ sensorMap.insert("inputZ", mutateBrainIn(sensorMap["inputZ"].toObject()));
break;
case contactSensor:
- sensorMap.insert("collisionInput", mutateBrainIn(sensorMap["collisionInput"]));
+ sensorMap.insert("collisionInput", mutateBrainIn(sensorMap["collisionInput"].toObject()));
break;
case boxSmellSensor:
- sensorMap.insert("intensityInput", mutateBrainIn(sensorMap["intensityInput"]));
+ sensorMap.insert("intensityInput", mutateBrainIn(sensorMap["intensityInput"].toObject()));
// TODO mutate radius of smell...
break;
case distanceSensor:
- sensorMap.insert("distanceInput", mutateBrainIn(sensorMap["distanceInput"]));
- QVariantMap orientationMap = sensorMap["orientation"].toMap();
+ sensorMap.insert("distanceInput", mutateBrainIn(sensorMap["distanceInput"].toObject()));
+ QJsonObject orientationMap = sensorMap["orientation"].toObject();
distanceSensorYZ->mutate(orientationMap,"y");
distanceSensorYZ->mutate(orientationMap,"z");
sensorMap.insert("orientation",orientationMap);
@@ -596,8 +589,8 @@ namespace GeneCraftCore {
// ------------------------
// -- Effector mutations --
// ------------------------
- QVariantList effectorList = fixMap["effectors"].toList();
- QVariantList newEffectorsList;
+ QJsonArray effectorList = fixMap["effectors"].toArray();
+ QJsonArray newEffectorsList;
// remove / replace
int nbEffectors = effectorList.count();
@@ -617,20 +610,20 @@ namespace GeneCraftCore {
}
// if motor exists
- foreach(QVariant effector, effectorList) {
- QVariantMap effectorMap = effector.toMap();
+ foreach(QJsonValue effector, effectorList) {
+ QJsonObject effectorMap = effector.toObject();
switch((EffectorType) effectorMap["type"].toInt()) {
case rotationalMotorEffector:
// do in bone mutation...
break;
case gripperEffector :
- effectorMap.insert("gripperOutput", mutateBrainOut(effectorMap["gripperOutput"]));
+ effectorMap.insert("gripperOutput", mutateBrainOut(effectorMap["gripperOutput"].toObject()));
break;
case flyingEffector :
- effectorMap.insert("impulseX", mutateBrainOut(effectorMap["impulseX"]));
- effectorMap.insert("impulseY", mutateBrainOut(effectorMap["impulseY"]));
- effectorMap.insert("impulseZ", mutateBrainOut(effectorMap["impulseZ"]));
+ effectorMap.insert("impulseX", mutateBrainOut(effectorMap["impulseX"].toObject()));
+ effectorMap.insert("impulseY", mutateBrainOut(effectorMap["impulseY"].toObject()));
+ effectorMap.insert("impulseZ", mutateBrainOut(effectorMap["impulseZ"].toObject()));
break;
}
@@ -648,14 +641,14 @@ namespace GeneCraftCore {
// ---------------------
// -- Bones mutations --
// ---------------------
- QVariantList bonesList = fixMap["bones"].toList();
+ QJsonArray bonesList = fixMap["bones"].toArray();
for(int i=0;icheckDelete()) {
- QVariantMap boneMap = bonesList.takeAt(i).toMap();
- QVariantMap fixMap = boneMap["endFix"].toMap();
- QVariantList bones = fixMap["bones"].toList();
+ QJsonObject boneMap = bonesList.takeAt(i).toObject();
+ QJsonObject fixMap = boneMap["endFix"].toObject();
+ QJsonArray bones = fixMap["bones"].toArray();
bonesList.append(bones);
i--;
}
@@ -663,17 +656,17 @@ namespace GeneCraftCore {
else if(bonesStructural->checkAdd()) {
// Un copie de l'os précédent est plus intéressante qu'un os totalement random
// The new bone
- QVariant oldBone = bonesList.takeAt(i);
- QVariantMap newBoneMap = oldBone.toMap();
+ QJsonValue oldBone = bonesList.takeAt(i);
+ QJsonObject newBoneMap = oldBone.toObject();
this->boneLength->mutate(newBoneMap, "length");
this->boneRadius->mutate(newBoneMap, "radius");
// And his fixation
- QVariantMap newEndFixation = newBoneMap["endFix"].toMap();
+ QJsonObject newEndFixation = newBoneMap["endFix"].toObject();
this->fixRadius->mutate(newEndFixation, "radius");
// The son
- QVariantList newBones;
+ QJsonArray newBones;
newBones.append(oldBone);
newEndFixation.remove("bones");
newEndFixation.insert("bones", newBones);
@@ -686,8 +679,8 @@ namespace GeneCraftCore {
}
// Replace
else if(bonesStructural->checkReplace()) {
- QVariantMap boneMap = bonesList.takeAt(i).toMap();
- QVariant endFix = boneMap["endFix"];
+ QJsonObject boneMap = bonesList.takeAt(i).toObject();
+ QJsonObject endFix = boneMap["endFix"].toObject();
addBone(bonesList,i, endFix); // Took the old endFix back
}
}
@@ -704,10 +697,10 @@ namespace GeneCraftCore {
return fixMap;
}
- void MutationsManager::addBone(QVariantList &bonesList, int i, QVariant endFix) {
- QVariantMap newBone = Bone::generateEmpty().toMap();
+ void MutationsManager::addBone(QJsonArray &bonesList, int i, QJsonObject endFix) {
+ QJsonObject newBone = Bone::generateEmpty();
- if(endFix != QVariant()) {
+ if(endFix != QJsonObject()) {
newBone.remove("endFix");
newBone.insert("endFix", endFix);
}
@@ -720,10 +713,10 @@ namespace GeneCraftCore {
}
// add sensor
- void MutationsManager::addSensor(QVariantList &sensorsList, int i) {
+ void MutationsManager::addSensor(QJsonArray &sensorsList, int i) {
MutationElement *me = sensorsStructuralList->pickOne();
- QVariant newSensor;
+ QJsonObject newSensor;
switch((SensorType) me->type) {
case accelerometerSensor:
@@ -754,10 +747,10 @@ namespace GeneCraftCore {
}
// add effector
- void MutationsManager::addEffector(QVariantList &effectorsList, int i) {
+ void MutationsManager::addEffector(QJsonArray &effectorsList, int i) {
MutationElement *me = effectorsStructuralList->pickOne();
- QVariant newEffector;
+ QJsonObject newEffector;
switch((EffectorType) me->type) {
case rotationalMotorEffector:
@@ -781,22 +774,20 @@ namespace GeneCraftCore {
// Mutate the brain
- QVariant MutationsManager::mutateBrain(QVariant brain) {
- QVariantMap brainMap = brain.toMap();
- brainFrequency->mutate(brainMap, "frequency");
- return brainMap;
+ QJsonObject MutationsManager::mutateBrain(QJsonObject brain) {
+ brainFrequency->mutate(brain, "frequency");
+ return brain;
}
// Mutate a brainInput
- QVariant MutationsManager::mutateBrainIn(QVariant brainIn) {
+ QJsonObject MutationsManager::mutateBrainIn(QJsonObject brainIn) {
// "inputRoll":{"connexions":[{"w":-0.0762658,"x":0.471847,"y":0.920957}
- QVariantMap inMap = brainIn.toMap();
- QVariantList connexions = inMap["connexions"].toList();
- QVariantList newConnexions;
+ QJsonArray connexions = brainIn["connexions"].toArray();
+ QJsonArray newConnexions;
- foreach(QVariant connexion, connexions) {
+ foreach(QJsonValue connexion, connexions) {
// To map !
- QVariantMap connexionMap = connexion.toMap();
+ QJsonObject connexionMap = connexion.toObject();
// mutation of position
brainInPos->mutate(connexionMap, "x");
@@ -810,17 +801,15 @@ namespace GeneCraftCore {
newConnexions.append(connexionMap);
}
- inMap.remove("connexions");
- inMap.insert("connexions", newConnexions);
+ brainIn.remove("connexions");
+ brainIn.insert("connexions", newConnexions);
- return inMap;
+ return brainIn;
}
// Mutate a brainOutput
- QVariant MutationsManager::mutateBrainOut(QVariant brainOut) {
- QVariantMap outMap = brainOut.toMap();
-
- QString treeData = outMap["connexionInfo"].toString();
+ QJsonObject MutationsManager::mutateBrainOut(QJsonObject brainOut) {
+ QString treeData = brainOut["connexionInfo"].toString();
QStringList nodes = treeData.split(",", QString::SkipEmptyParts);
QString newConnexionInfo;
@@ -985,15 +974,15 @@ namespace GeneCraftCore {
// x et y
newConnexionInfo.append(nodePart[0]);
newConnexionInfo.append(" " +
- QString::number(brainInPos->mutate(nodePart[1].toFloat())));
+ QString::number(brainInPos->mutate(nodePart[1].toDouble())));
newConnexionInfo.append(" " +
- QString::number(brainInPos->mutate(nodePart[2].toFloat())));
+ QString::number(brainInPos->mutate(nodePart[2].toDouble())));
newConnexionInfo.append(",");
break;
case CONSTANT:
newConnexionInfo.append(nodePart[0]);
newConnexionInfo.append(" " +
- QString::number(constValue->mutate(nodePart[1].toFloat())));
+ QString::number(constValue->mutate(nodePart[1].toDouble())));
newConnexionInfo.append(",");
break;
case INTEGRATE:
@@ -1015,7 +1004,7 @@ namespace GeneCraftCore {
case WAVE:
newConnexionInfo.append(nodePart[0]);
newConnexionInfo.append(" " +
- QString::number(constValue->mutate(nodePart[1].toFloat())));
+ QString::number(constValue->mutate(nodePart[1].toDouble())));
newConnexionInfo.append(",");
break;
@@ -1026,10 +1015,10 @@ namespace GeneCraftCore {
}
}
- outMap.remove("connexionInfo");
- outMap.insert("connexionInfo", newConnexionInfo);
+ brainOut.remove("connexionInfo");
+ brainOut.insert("connexionInfo", newConnexionInfo);
- return outMap;
+ return brainOut;
}
void MutationsManager::consumnSubTree(QStringList::iterator &it) {
diff --git a/src/genecraft/core/entities/mutation/mutationsmanager.h b/src/genecraft/core/entities/mutation/mutationsmanager.h
index fe78e56..5ee18b1 100644
--- a/src/genecraft/core/entities/mutation/mutationsmanager.h
+++ b/src/genecraft/core/entities/mutation/mutationsmanager.h
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef MUTATIONSMANAGER_H
#define MUTATIONSMANAGER_H
-#include
+#include
#include
#include
#include "body/bone.h"
@@ -36,33 +36,33 @@ class MutationsManager
// To create the mutation manager
MutationsManager();
- MutationsManager(QVariant mutationsParams);
+ MutationsManager(QJsonObject mutationsParams);
~MutationsManager();
- QVariant serialize();
+ QJsonObject serialize();
// To mutate an entire entity
- QVariant mutateEntity(const QVariant &entityVariant);
+ QJsonObject mutateEntity(const QJsonObject &entityVariant);
// To mutate a treeshape
- QVariant mutateTreeShape(const QVariant &treeShapeVariant);
+ QJsonObject mutateTreeShape(const QJsonObject &treeShapeVariant);
// To mutate a fixation (Not recursively)
- QVariant mutateBone(const QVariant &boneVariant);
+ QJsonObject mutateBone(const QJsonObject &boneVariant);
// To mutate a fixation (Not recursively)
- QVariant mutateFixation(const QVariant &fixVariant);
+ QJsonObject mutateFixation(const QJsonObject &fixVariant);
// Mutate the brain
- QVariant mutateBrain(QVariant brain);
+ QJsonObject mutateBrain(QJsonObject brain);
// Mutate a brainInput
- QVariant mutateBrainIn(QVariant brainIn);
+ QJsonObject mutateBrainIn(QJsonObject brainIn);
// Mutate a brainOutput
- QVariant mutateBrainOut(QVariant brainOut);
+ QJsonObject mutateBrainOut(QJsonObject brainOut);
// Mutate the tree of a brainOutput
- QVariant mutateBrainOutTree(QVariant brainOut);
+ QJsonObject mutateBrainOutTree(QJsonObject brainOut);
// ----------
// -- body --
@@ -126,36 +126,36 @@ class MutationsManager
private:
// To mutate a value in a map
- void mutate(QVariantMap &map, QString key, Mutation* mutation);
+ void mutate(QJsonObject &map, QString key, Mutation* mutation);
int treeDepth(QStringList::iterator& it);
void consumnSubTree(QStringList::iterator& it);
/**
* To add sensor
*
- * @param the QVariantList where add
+ * @param the QJsonArray where add
* @param the position to add (-1 = end of list)
*/
- void addSensor(QVariantList &sensors, int i=-1);
+ void addSensor(QJsonArray &sensors, int i=-1);
/**
* To add effector
*
- * @param the QVariantList where add
+ * @param the QJsonArray where add
* @param the position to add (-1 = end of list)
*/
- void addEffector(QVariantList &effectorsList, int i=-1);
+ void addEffector(QJsonArray &effectorsList, int i=-1);
/**
* To add bone
*
- * @param the QVariantList where add
+ * @param the QJsonArray where add
* @param the position to add (-1 = end of list)
*/
- void addBone(QVariantList &bones, int i=-1, QVariant endFix = QVariant());
+ void addBone(QJsonArray &bones, int i=-1, QJsonObject endFix = QJsonObject());
- QVariant recursiveMutateTreeShape(QVariant &boneVariant);
+ QJsonObject recursiveMutateTreeShape(QJsonObject &boneVariant);
};
diff --git a/src/genecraft/core/entities/mutation/simpleprobabilitymutation.cpp b/src/genecraft/core/entities/mutation/simpleprobabilitymutation.cpp
index d89fec5..e2f3ba5 100644
--- a/src/genecraft/core/entities/mutation/simpleprobabilitymutation.cpp
+++ b/src/genecraft/core/entities/mutation/simpleprobabilitymutation.cpp
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#include "simpleprobabilitymutation.h"
#include
-#include
+#include
namespace GeneCraftCore {
@@ -29,8 +29,7 @@ SimpleProbabilityMutation::SimpleProbabilityMutation(){
enable = true;
}
-SimpleProbabilityMutation::SimpleProbabilityMutation(QVariant variant){
- QVariantMap map = variant.toMap();
+SimpleProbabilityMutation::SimpleProbabilityMutation(QJsonObject map){
if(map["type"].toInt() == SimpleProbabilityType) {
probability = map["probability"].toDouble();
@@ -40,13 +39,13 @@ SimpleProbabilityMutation::SimpleProbabilityMutation(QVariant variant){
qDebug() << Q_FUNC_INFO << "Wrong mutation type" << map["Type"].toInt();
}
-QVariant SimpleProbabilityMutation::serialize(){
+QJsonObject SimpleProbabilityMutation::serialize(){
- QVariantMap map;
+ QJsonObject map;
- map.insert("type",QVariant(SimpleProbabilityType));
- map.insert("probability",QVariant((double)probability));
- map.insert("enable",QVariant(enable));
+ map.insert("type",SimpleProbabilityType);
+ map.insert("probability",(double)probability);
+ map.insert("enable",enable);
return map;
}
diff --git a/src/genecraft/core/entities/mutation/simpleprobabilitymutation.h b/src/genecraft/core/entities/mutation/simpleprobabilitymutation.h
index df72199..446dae9 100644
--- a/src/genecraft/core/entities/mutation/simpleprobabilitymutation.h
+++ b/src/genecraft/core/entities/mutation/simpleprobabilitymutation.h
@@ -28,8 +28,8 @@ namespace GeneCraftCore {
public:
SimpleProbabilityMutation();
- SimpleProbabilityMutation(QVariant variant);
- QVariant serialize();
+ SimpleProbabilityMutation(QJsonObject variant);
+ QJsonObject serialize();
};
}
diff --git a/src/genecraft/core/entities/mutation/structurallist.cpp b/src/genecraft/core/entities/mutation/structurallist.cpp
index 129be18..a0d5733 100644
--- a/src/genecraft/core/entities/mutation/structurallist.cpp
+++ b/src/genecraft/core/entities/mutation/structurallist.cpp
@@ -21,6 +21,7 @@ along with Genecraft-Project. If not, see .
#include "tools.h"
#include
+#include
namespace GeneCraftCore {
@@ -34,21 +35,20 @@ MutationElement::MutationElement(QString name, int type, btScalar weight) {
this->weight = weight;
}
-MutationElement::MutationElement(QVariant variant) {
- QVariantMap map = variant.toMap();
+MutationElement::MutationElement(QJsonObject map) {
name = map["name"].toString();
type = map["type"].toInt();
- if(map["weight"].toFloat() < 0.0)
+ if(map["weight"].toDouble() < 0.0)
weight = 0.0;
else
- weight = map["weight"].toFloat();
+ weight = map["weight"].toDouble();
}
-QVariant MutationElement::serialize() {
+QJsonObject MutationElement::serialize() {
- QVariantMap map;
+ QJsonObject map;
map.insert("name",name);
map.insert("type",type);
@@ -64,10 +64,9 @@ StructuralList::~StructuralList() {
elements.clear();
}
-StructuralList::StructuralList(QVariant variant) {
- QVariantList list = variant.toList();
- foreach(QVariant variant, list)
- elements.append(new MutationElement(variant));
+StructuralList::StructuralList(QJsonArray list) {
+ foreach(QJsonValue variant, list)
+ elements.append(new MutationElement(variant.toObject()));
}
MutationElement *StructuralList::pickOne() {
@@ -94,8 +93,8 @@ MutationElement *StructuralList::pickOne() {
return elements.last();
}
-QVariant StructuralList::serialize() {
- QVariantList list;
+QJsonArray StructuralList::serialize() {
+ QJsonArray list;
foreach(MutationElement *element, elements)
list.append(element->serialize());
diff --git a/src/genecraft/core/entities/mutation/structurallist.h b/src/genecraft/core/entities/mutation/structurallist.h
index 2fc878c..13a4ce2 100644
--- a/src/genecraft/core/entities/mutation/structurallist.h
+++ b/src/genecraft/core/entities/mutation/structurallist.h
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef STRUCTURALLIST_H
#define STRUCTURALLIST_H
-#include
+#include
#include
#include "LinearMath/btScalar.h"
@@ -30,8 +30,8 @@ class MutationElement {
public:
MutationElement(QString name, int type, btScalar weight);
- MutationElement(QVariant variant);
- QVariant serialize();
+ MutationElement(QJsonObject variant);
+ QJsonObject serialize();
QString name;
int type;
@@ -42,9 +42,9 @@ class StructuralList
{
public:
StructuralList();
- StructuralList(QVariant variant);
+ StructuralList(QJsonArray variant);
~StructuralList();
- QVariant serialize();
+ QJsonArray serialize();
MutationElement * pickOne();
QList elements;
diff --git a/src/genecraft/core/entities/mutation/structuralmutation.cpp b/src/genecraft/core/entities/mutation/structuralmutation.cpp
index 94ab4e2..90a1f4b 100644
--- a/src/genecraft/core/entities/mutation/structuralmutation.cpp
+++ b/src/genecraft/core/entities/mutation/structuralmutation.cpp
@@ -33,9 +33,8 @@ StructuralMutation::StructuralMutation()
replaceProbability = .5f;
}
-StructuralMutation::StructuralMutation(QVariant variant)
+StructuralMutation::StructuralMutation(QJsonObject map)
{
- QVariantMap map = variant.toMap();
enable = map["enable"].toBool();
addProbability = map["addProbability"].toDouble();
@@ -58,8 +57,8 @@ bool StructuralMutation::checkReplace()
return enable && Tools::random(0.f,1.f) <= replaceProbability;
}
-QVariant StructuralMutation::serialize() {
- QVariantMap map;
+QJsonObject StructuralMutation::serialize() {
+ QJsonObject map;
map.insert("enable",enable);
map.insert("addProbability",(double)addProbability);
diff --git a/src/genecraft/core/entities/mutation/structuralmutation.h b/src/genecraft/core/entities/mutation/structuralmutation.h
index 064480e..838f831 100644
--- a/src/genecraft/core/entities/mutation/structuralmutation.h
+++ b/src/genecraft/core/entities/mutation/structuralmutation.h
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef STRUCTURALMUTATION_H
#define STRUCTURALMUTATION_H
-#include
+#include
#include "LinearMath/btScalar.h"
namespace GeneCraftCore {
@@ -29,8 +29,8 @@ class StructuralMutation
{
public:
StructuralMutation();
- StructuralMutation(QVariant variant);
- QVariant serialize();
+ StructuralMutation(QJsonObject variant);
+ QJsonObject serialize();
bool checkAdd();
bool checkDelete();
diff --git a/src/genecraft/core/entities/sensors/accelerometersensor.cpp b/src/genecraft/core/entities/sensors/accelerometersensor.cpp
index 8c7d08b..c6ea8c2 100644
--- a/src/genecraft/core/entities/sensors/accelerometersensor.cpp
+++ b/src/genecraft/core/entities/sensors/accelerometersensor.cpp
@@ -22,7 +22,6 @@ along with Genecraft-Project. If not, see .
#include "brain/brainin.h"
#include "body/fixation.h"
#include
-#include
#include "tools.h"
#define MIN_ACCELERATION -1.0
@@ -51,11 +50,11 @@ AccelerometerSensor::AccelerometerSensor(Fixation *fixation) : Sensor(fixation)
tmpMinAcc = tmpMaxAcc = 0;
}
-AccelerometerSensor::AccelerometerSensor(QVariant data, Fixation * fixation) : Sensor(data, fixation) {
+AccelerometerSensor::AccelerometerSensor(QJsonObject data, Fixation * fixation) : Sensor(data, fixation) {
- inputX = new BrainIn(data.toMap()["inputX"]);
- inputY = new BrainIn(data.toMap()["inputY"]);
- inputZ = new BrainIn(data.toMap()["inputZ"]);
+ inputX = new BrainIn(data["inputX"].toObject());
+ inputY = new BrainIn(data["inputY"].toObject());
+ inputZ = new BrainIn(data["inputZ"].toObject());
brainInputs.append(inputX);
brainInputs.append(inputY);
@@ -68,9 +67,9 @@ AccelerometerSensor::AccelerometerSensor(QVariant data, Fixation * fixation) : S
tmpMinAcc = tmpMaxAcc = 0;
}
-QVariant AccelerometerSensor::generateEmpty()
+QJsonObject AccelerometerSensor::generateEmpty()
{
- QVariantMap data = Sensor::generateEmpty("Accelerometer sensor", accelerometerSensor).toMap();
+ QJsonObject data = Sensor::generateEmpty("Accelerometer sensor", accelerometerSensor);
BrainIn inputX(MIN_ACCELERATION,MAX_ACCELERATION);
BrainIn inputY(MIN_ACCELERATION,MAX_ACCELERATION);
@@ -87,8 +86,8 @@ QVariant AccelerometerSensor::generateEmpty()
return data;
}
-QVariant AccelerometerSensor::serialize() {
- QVariantMap data = Sensor::serialize().toMap();
+QJsonObject AccelerometerSensor::serialize() {
+ QJsonObject data = Sensor::serialize();
data.insert("inputX", inputX->serialize());
data.insert("inputY", inputY->serialize());
diff --git a/src/genecraft/core/entities/sensors/accelerometersensor.h b/src/genecraft/core/entities/sensors/accelerometersensor.h
index b75cd59..2f73a07 100644
--- a/src/genecraft/core/entities/sensors/accelerometersensor.h
+++ b/src/genecraft/core/entities/sensors/accelerometersensor.h
@@ -45,13 +45,13 @@ class AccelerometerSensor : public Sensor
AccelerometerSensor(Fixation * fixation);
// To create from serialization data
- AccelerometerSensor(QVariant data, Fixation * fixation);
+ AccelerometerSensor(QJsonObject data, Fixation * fixation);
// To create an empty sensor
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// To serialize
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
// To update brain inputs values
void step();
diff --git a/src/genecraft/core/entities/sensors/boxsmellsensor.cpp b/src/genecraft/core/entities/sensors/boxsmellsensor.cpp
index 1de7d9c..d2c27b5 100644
--- a/src/genecraft/core/entities/sensors/boxsmellsensor.cpp
+++ b/src/genecraft/core/entities/sensors/boxsmellsensor.cpp
@@ -19,8 +19,6 @@ along with Genecraft-Project. If not, see .
#include "boxsmellsensor.h"
-#include
-
#define RADIUS_OF_SMELL 20.0
namespace GeneCraftCore {
@@ -31,12 +29,12 @@ BoxSmellSensor::BoxSmellSensor(Fixation *fixation) :
}
// To create from serialization data
-BoxSmellSensor::BoxSmellSensor(QVariant data, Fixation * fixation) :
+BoxSmellSensor::BoxSmellSensor(QJsonObject data, Fixation * fixation) :
SmellSensor(data, RigidBodyOrigin::BASIC_SHAPE, fixation)
{
}
-QVariant BoxSmellSensor::generateEmpty()
+QJsonObject BoxSmellSensor::generateEmpty()
{
return SmellSensor::generateEmpty("Box smell sensor", boxSmellSensor, RADIUS_OF_SMELL);
}
diff --git a/src/genecraft/core/entities/sensors/boxsmellsensor.h b/src/genecraft/core/entities/sensors/boxsmellsensor.h
index 715b280..0bd08d7 100644
--- a/src/genecraft/core/entities/sensors/boxsmellsensor.h
+++ b/src/genecraft/core/entities/sensors/boxsmellsensor.h
@@ -30,10 +30,10 @@ class BoxSmellSensor : public SmellSensor
BoxSmellSensor(Fixation *fixation);
// To create from serialization data
- BoxSmellSensor(QVariant data, Fixation * fixation);
+ BoxSmellSensor(QJsonObject data, Fixation * fixation);
// To generate an empty sensor serialization data
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
};
}
diff --git a/src/genecraft/core/entities/sensors/contactsensor.cpp b/src/genecraft/core/entities/sensors/contactsensor.cpp
index aedbacc..cd1841c 100644
--- a/src/genecraft/core/entities/sensors/contactsensor.cpp
+++ b/src/genecraft/core/entities/sensors/contactsensor.cpp
@@ -39,24 +39,24 @@ ContactSensor::ContactSensor(Fixation * fixation) : Sensor(fixation)
}
// To create from serialization data
-ContactSensor::ContactSensor(QVariant data, Fixation * fixation) : Sensor(data, fixation) {
+ContactSensor::ContactSensor(QJsonObject data, Fixation * fixation) : Sensor(data, fixation) {
- collided = new BrainIn(data.toMap()["collisionInput"]);
+ collided = new BrainIn(data["collisionInput"].toObject());
brainInputs.append(collided);
}
// To serialize
-QVariant ContactSensor::serialize()
+QJsonObject ContactSensor::serialize()
{
- QVariantMap data = Sensor::serialize().toMap();
+ QJsonObject data = Sensor::serialize();
data.insert("collisionInput", collided->serialize());
return data;
}
-QVariant ContactSensor::generateEmpty()
+QJsonObject ContactSensor::generateEmpty()
{
- QVariantMap data = Sensor::generateEmpty("Contact sensor", contactSensor).toMap();
+ QJsonObject data = Sensor::generateEmpty("Contact sensor", contactSensor);
BrainIn collided(0,1);
@@ -90,13 +90,13 @@ void ContactSensor::step() {
for (int i=0;igetShapesFactory()->getWorld()->getBulletWorld()->getDispatcher()->getManifoldByIndexInternal(i);
- btCollisionObject* obA = static_cast(contactManifold->getBody0());
- btCollisionObject* obB = static_cast(contactManifold->getBody1());
+ const btCollisionObject* obA = static_cast(contactManifold->getBody0());
+ const btCollisionObject* obB = static_cast(contactManifold->getBody1());
// contact ?
if(contactManifold->getNumContacts() > 0)
{
- btCollisionObject* object;
+ const btCollisionObject* object;
// get object in contact
if(obA == (btCollisionObject *) fixation->getRigidBody())
diff --git a/src/genecraft/core/entities/sensors/contactsensor.h b/src/genecraft/core/entities/sensors/contactsensor.h
index e265d18..e5625e6 100644
--- a/src/genecraft/core/entities/sensors/contactsensor.h
+++ b/src/genecraft/core/entities/sensors/contactsensor.h
@@ -23,7 +23,6 @@ along with Genecraft-Project. If not, see .
#include "genecraftcoreclasses.h"
#include "sensor.h"
#include "LinearMath/btVector3.h"
-#include
#include "btBulletCollisionCommon.h"
namespace GeneCraftCore {
@@ -47,16 +46,16 @@ class ContactSensor : public Sensor
ContactSensor(Fixation * fixation);
// To create from serialization data
- ContactSensor(QVariant data, Fixation * fixation);
+ ContactSensor(QJsonObject data, Fixation * fixation);
// To indicate collision
//void collideStaticObject(const btCollisionObject *object, btVector3 contactPoint);
// To serialize
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
// To create empty sensor serialization data
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// To update brain inputs values
void step();
diff --git a/src/genecraft/core/entities/sensors/distancesensor.cpp b/src/genecraft/core/entities/sensors/distancesensor.cpp
index b7dcd76..50f4015 100644
--- a/src/genecraft/core/entities/sensors/distancesensor.cpp
+++ b/src/genecraft/core/entities/sensors/distancesensor.cpp
@@ -19,7 +19,6 @@ along with Genecraft-Project. If not, see .
#include "distancesensor.h"
-#include
#include "body/fixation.h"
#include "btshapesfactory.h"
#include "bullet/btworld.h"
@@ -42,23 +41,23 @@ DistanceSensor::DistanceSensor(Fixation *fixation, btScalar yAxis, btScalar zAxi
brainInputs.append(distanceInput);
}
-DistanceSensor::DistanceSensor(QVariant data, Fixation* fixation) : Sensor(data, fixation) {
+DistanceSensor::DistanceSensor(QJsonObject data, Fixation* fixation) : Sensor(data, fixation) {
- distanceInput = new BrainIn(data.toMap()["distanceInput"]);
+ distanceInput = new BrainIn(data["distanceInput"].toObject());
brainInputs.append(distanceInput);
- QVariantMap orientationMap = data.toMap()["orientation"].toMap();
+ QJsonObject orientationMap = data["orientation"].toObject();
- yAxis = orientationMap["y"].toFloat();
- zAxis = orientationMap["z"].toFloat();
+ yAxis = orientationMap["y"].toDouble();
+ zAxis = orientationMap["z"].toDouble();
}
-QVariant DistanceSensor::serialize() {
+QJsonObject DistanceSensor::serialize() {
- QVariantMap data = Sensor::serialize().toMap();
+ QJsonObject data = Sensor::serialize();
data.insert("distanceInput", distanceInput->serialize());
- QVariantMap orientationMap;
+ QJsonObject orientationMap;
orientationMap.insert("y",(double)yAxis);
orientationMap.insert("z",(double)zAxis);
data.insert("orientation",orientationMap);
@@ -86,7 +85,7 @@ void DistanceSensor::step() {
fixation->getShapesFactory()->getWorld()->getBulletWorld()->rayTest(rayFrom,realRayTo,rayCallback);
if(rayCallback.hasHit())
{
- btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
+ const btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
if(body) {
@@ -104,9 +103,9 @@ void DistanceSensor::step() {
distanceInput->setValue(0);
}
-QVariant DistanceSensor::generateEmpty()
+QJsonObject DistanceSensor::generateEmpty()
{
- QVariantMap data = Sensor::generateEmpty("Distance sensor", distanceSensor).toMap();
+ QJsonObject data = Sensor::generateEmpty("Distance sensor", distanceSensor);
BrainIn distanceInput(0,MAX_DISTANCE);
distanceInput.connectRandomly();
diff --git a/src/genecraft/core/entities/sensors/distancesensor.h b/src/genecraft/core/entities/sensors/distancesensor.h
index 802e06d..8397d77 100644
--- a/src/genecraft/core/entities/sensors/distancesensor.h
+++ b/src/genecraft/core/entities/sensors/distancesensor.h
@@ -34,13 +34,13 @@ class DistanceSensor : public Sensor
DistanceSensor(Fixation * fixation, btScalar yAxis, btScalar zAxis);
// To create from serialization data
- DistanceSensor(QVariant data, Fixation* fixation);
+ DistanceSensor(QJsonObject data, Fixation* fixation);
// To create empty sensor serialization data
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// To serialize
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
// To update brain inputs values
void step();
diff --git a/src/genecraft/core/entities/sensors/gyroscopicsensor.cpp b/src/genecraft/core/entities/sensors/gyroscopicsensor.cpp
index b86145b..f00d5ec 100644
--- a/src/genecraft/core/entities/sensors/gyroscopicsensor.cpp
+++ b/src/genecraft/core/entities/sensors/gyroscopicsensor.cpp
@@ -22,7 +22,6 @@ along with Genecraft-Project. If not, see .
#include "brain/brainin.h"
#include "body/fixation.h"
#include
-#include
#include "tools.h"
namespace GeneCraftCore {
@@ -41,19 +40,19 @@ GyroscopicSensor::GyroscopicSensor(Fixation *fixation) : Sensor(fixation){
brainInputs.append(inputRoll);
}
-GyroscopicSensor::GyroscopicSensor(QVariant data, Fixation* fixation) : Sensor(data, fixation) {
+GyroscopicSensor::GyroscopicSensor(QJsonObject data, Fixation* fixation) : Sensor(data, fixation) {
- inputYaw = new BrainIn(data.toMap()["inputYaw"]);
- inputPitch = new BrainIn(data.toMap()["inputPitch"]);
- inputRoll = new BrainIn(data.toMap()["inputRoll"]);
+ inputYaw = new BrainIn(data["inputYaw"].toObject());
+ inputPitch = new BrainIn(data["inputPitch"].toObject());
+ inputRoll = new BrainIn(data["inputRoll"].toObject());
brainInputs.append(inputYaw);
brainInputs.append(inputPitch);
brainInputs.append(inputRoll);
}
-QVariant GyroscopicSensor::serialize() {
- QVariantMap data = Sensor::serialize().toMap();
+QJsonObject GyroscopicSensor::serialize() {
+ QJsonObject data = Sensor::serialize();
data.insert("inputYaw", inputYaw->serialize());
data.insert("inputPitch", inputPitch->serialize());
data.insert("inputRoll", inputRoll->serialize());
@@ -61,9 +60,9 @@ QVariant GyroscopicSensor::serialize() {
return data;
}
-QVariant GyroscopicSensor::generateEmpty()
+QJsonObject GyroscopicSensor::generateEmpty()
{
- QVariantMap data = Sensor::generateEmpty("Gyroscopic sensor", gyroscopicSensor).toMap();
+ QJsonObject data = Sensor::generateEmpty("Gyroscopic sensor", gyroscopicSensor);
BrainIn inputYaw(-SIMD_PI, SIMD_PI);
BrainIn inputPitch(-SIMD_PI, SIMD_PI);
diff --git a/src/genecraft/core/entities/sensors/gyroscopicsensor.h b/src/genecraft/core/entities/sensors/gyroscopicsensor.h
index d60e4b9..85269b3 100644
--- a/src/genecraft/core/entities/sensors/gyroscopicsensor.h
+++ b/src/genecraft/core/entities/sensors/gyroscopicsensor.h
@@ -42,13 +42,13 @@ class GyroscopicSensor : public Sensor
GyroscopicSensor(Fixation * fixation);
// To create from serialization data
- GyroscopicSensor(QVariant data, Fixation* fixation);
+ GyroscopicSensor(QJsonObject data, Fixation* fixation);
// To serialize
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
// To create an empty sensor
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// To update brain inputs values
void step();
diff --git a/src/genecraft/core/entities/sensors/positionsensor.cpp b/src/genecraft/core/entities/sensors/positionsensor.cpp
index 1a40981..6a7d04b 100644
--- a/src/genecraft/core/entities/sensors/positionsensor.cpp
+++ b/src/genecraft/core/entities/sensors/positionsensor.cpp
@@ -22,7 +22,6 @@ along with Genecraft-Project. If not, see .
#include "brain/brainin.h"
#include "body/fixation.h"
#include
-#include
#include "tools.h"
// FIXME : max size of an entity is 10 in this case !
@@ -46,20 +45,20 @@ PositionSensor::PositionSensor(Fixation * rootFix, Fixation *fixation) : Sensor(
brainInputs.append(inputZ);
}
-PositionSensor::PositionSensor(QVariant data, Fixation* rootFix, Fixation* fixation) : Sensor(data, fixation) {
+PositionSensor::PositionSensor(QJsonObject data, Fixation* rootFix, Fixation* fixation) : Sensor(data, fixation) {
this->rootFix = rootFix;
- inputX = new BrainIn(data.toMap()["inputX"]);
- inputY = new BrainIn(data.toMap()["inputY"]);
- inputZ = new BrainIn(data.toMap()["inputZ"]);
+ inputX = new BrainIn(data["inputX"].toObject());
+ inputY = new BrainIn(data["inputY"].toObject());
+ inputZ = new BrainIn(data["inputZ"].toObject());
brainInputs.append(inputX);
brainInputs.append(inputY);
brainInputs.append(inputZ);
}
-QVariant PositionSensor::serialize() {
- QVariantMap data = Sensor::serialize().toMap();
+QJsonObject PositionSensor::serialize() {
+ QJsonObject data = Sensor::serialize();
data.insert("inputX", inputX->serialize());
data.insert("inputY", inputY->serialize());
data.insert("inputZ", inputZ->serialize());
@@ -67,9 +66,9 @@ QVariant PositionSensor::serialize() {
return data;
}
-QVariant PositionSensor::generateEmpty()
+QJsonObject PositionSensor::generateEmpty()
{
- QVariantMap data = Sensor::generateEmpty("Egocentric position sensor", positionSensor).toMap();
+ QJsonObject data = Sensor::generateEmpty("Egocentric position sensor", positionSensor);
BrainIn inputX(minDistanceBetweenRootFixAndThisFix,maxDistanceBetweenRootFixAndThisFix);
BrainIn inputY(minDistanceBetweenRootFixAndThisFix,maxDistanceBetweenRootFixAndThisFix);
diff --git a/src/genecraft/core/entities/sensors/positionsensor.h b/src/genecraft/core/entities/sensors/positionsensor.h
index 463f39f..3895b7a 100644
--- a/src/genecraft/core/entities/sensors/positionsensor.h
+++ b/src/genecraft/core/entities/sensors/positionsensor.h
@@ -47,13 +47,13 @@ class PositionSensor : public Sensor
PositionSensor(Fixation * rootFix, Fixation * fixation);
// To create from serialization data
- PositionSensor(QVariant data, Fixation* rootFix, Fixation* fixation);
+ PositionSensor(QJsonObject data, Fixation* rootFix, Fixation* fixation);
// To serialize
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
// To create an empty sensor
- static QVariant generateEmpty();
+ static QJsonObject generateEmpty();
// To update brain inputs values
void step();
diff --git a/src/genecraft/core/entities/sensors/sensor.cpp b/src/genecraft/core/entities/sensors/sensor.cpp
index 2a46524..a442437 100644
--- a/src/genecraft/core/entities/sensors/sensor.cpp
+++ b/src/genecraft/core/entities/sensors/sensor.cpp
@@ -18,7 +18,6 @@ along with Genecraft-Project. If not, see .
*/
#include "sensor.h"
-#include
namespace GeneCraftCore {
Sensor::Sensor(Fixation * fixation, QObject *parent) :
@@ -28,21 +27,21 @@ namespace GeneCraftCore {
}
- Sensor::Sensor(QVariant data, Fixation* fixation) {
+ Sensor::Sensor(QJsonObject data, Fixation* fixation) {
this->fixation = fixation;
- this->typeName = data.toMap()["typeName"].toString();
- this->type = (SensorType)data.toMap()["type"].toInt();
+ this->typeName = data["typeName"].toString();
+ this->type = (SensorType)data["type"].toInt();
}
- QVariant Sensor::serialize() {
- QVariantMap data;
+ QJsonObject Sensor::serialize() {
+ QJsonObject data;
data.insert("typeName", this->typeName);
data.insert("type", (int)this->type);
return data;
}
- QVariant Sensor::generateEmpty(QString typeName, int type) {
- QVariantMap data;
+ QJsonObject Sensor::generateEmpty(QString typeName, int type) {
+ QJsonObject data;
data.insert("typeName", typeName);
data.insert("type", type);
return data;
diff --git a/src/genecraft/core/entities/sensors/sensor.h b/src/genecraft/core/entities/sensors/sensor.h
index e47bcc6..a4932fa 100644
--- a/src/genecraft/core/entities/sensors/sensor.h
+++ b/src/genecraft/core/entities/sensors/sensor.h
@@ -21,6 +21,7 @@ along with Genecraft-Project. If not, see .
#define SENSOR_H
#include
+#include
#include
#include "genecraftcoreclasses.h"
@@ -49,10 +50,10 @@ class Sensor : public QObject
explicit Sensor(Fixation * fixation, QObject *parent = 0);
// To create a sensor from serialization data
- Sensor(QVariant data, Fixation* fixation);
+ Sensor(QJsonObject data, Fixation* fixation);
// To generate empty sensor
- static QVariant generateEmpty(QString typeName, int type);
+ static QJsonObject generateEmpty(QString typeName, int type);
// To delete the sensor
~Sensor() {
@@ -63,7 +64,7 @@ class Sensor : public QObject
}
// To serialize
- virtual QVariant serialize();
+ virtual QJsonObject serialize();
// To get the type name
const QString &getTypeName() { return typeName; }
diff --git a/src/genecraft/core/entities/sensors/smellsensor.cpp b/src/genecraft/core/entities/sensors/smellsensor.cpp
index ff687fd..541170d 100644
--- a/src/genecraft/core/entities/sensors/smellsensor.cpp
+++ b/src/genecraft/core/entities/sensors/smellsensor.cpp
@@ -50,15 +50,13 @@ SmellSensor::SmellSensor(Fixation *fixation, QString typeName, SensorType type,
}
// To create from serialization data
-SmellSensor::SmellSensor(QVariant data, RigidBodyOrigin::RigidBodyType smellType, Fixation * fixation) : Sensor(data, fixation)
+SmellSensor::SmellSensor(QJsonObject data, RigidBodyOrigin::RigidBodyType smellType, Fixation * fixation) : Sensor(data, fixation)
{
- QVariantMap map = data.toMap();
-
this->smellType = smellType;
- intensityInput = new BrainIn(map["intensityInput"]);
+ intensityInput = new BrainIn(data["intensityInput"].toObject());
// the max value equals radius of smell !
- radiusOfSmell = map["radiusOfSmell"].toFloat();
+ radiusOfSmell = data["radiusOfSmell"].toDouble();
//intensityInput->setMax(radiusOfSmell);
brainInputs.append(intensityInput);
@@ -83,9 +81,9 @@ void SmellSensor::createRigidBody(btScalar radiusOfSmell) {
}
// To serialize
-QVariant SmellSensor::serialize()
+QJsonObject SmellSensor::serialize()
{
- QVariantMap data = Sensor::serialize().toMap();
+ QJsonObject data = Sensor::serialize();
data.insert("intensityInput", intensityInput->serialize());
data.insert("radiusOfSmell", (double) radiusOfSmell);
@@ -155,9 +153,9 @@ void SmellSensor::objectSmelled(const btRigidBody *body) {
}
}
-QVariant SmellSensor::generateEmpty(QString typeName, SensorType type, btScalar radiusOfSmell)
+QJsonObject SmellSensor::generateEmpty(QString typeName, SensorType type, btScalar radiusOfSmell)
{
- QVariantMap data = Sensor::generateEmpty(typeName, type).toMap();
+ QJsonObject data = Sensor::generateEmpty(typeName, type);
BrainIn intensity(0, radiusOfSmell);
intensity.connectRandomly();
diff --git a/src/genecraft/core/entities/sensors/smellsensor.h b/src/genecraft/core/entities/sensors/smellsensor.h
index e2d6980..23a2676 100644
--- a/src/genecraft/core/entities/sensors/smellsensor.h
+++ b/src/genecraft/core/entities/sensors/smellsensor.h
@@ -20,6 +20,8 @@ along with Genecraft-Project. If not, see .
#ifndef SMELLSENSOR_H
#define SMELLSENSOR_H
+#include
+
#include "genecraftcoreclasses.h"
#include "sensor.h"
@@ -38,14 +40,14 @@ class SmellSensor : public Sensor
SmellSensor(Fixation *fixation, QString typeName, SensorType type, RigidBodyOrigin::RigidBodyType smellType, btScalar radiusOfSmell);
// To create from serialization data
- SmellSensor(QVariant data, RigidBodyOrigin::RigidBodyType smellType, Fixation * fixation);
+ SmellSensor(QJsonObject data, RigidBodyOrigin::RigidBodyType smellType, Fixation * fixation);
~SmellSensor();
// To serialize
- QVariant serialize();
+ QJsonObject serialize();
// To generate en empty sensor serialization data
- static QVariant generateEmpty(QString typeName, SensorType type, btScalar radiusOfSmell);
+ static QJsonObject generateEmpty(QString typeName, SensorType type, btScalar radiusOfSmell);
// To update brain inputs values
void step();
@@ -75,6 +77,9 @@ class SmellSensor : public Sensor
};
+
+
+
struct ContactSensorCallback : public btCollisionWorld::ContactResultCallback {
//! Constructor, pass whatever context you want to have available when processing contacts
@@ -98,26 +103,28 @@ struct ContactSensorCallback : public btCollisionWorld::ContactResultCallback {
// return body.checkCollideWithOverride(static_cast(proxy->m_clientObject));
// }
+
//! Called with each contact for your own processing (e.g. test if contacts fall in within sensor parameters)
virtual btScalar addSingleResult(btManifoldPoint& cp,
- const btCollisionObject* colObj0,int,int,
- const btCollisionObject* colObj1,int,int)
+ const btCollisionObjectWrapper* colObj0,int,int,
+ const btCollisionObjectWrapper* colObj1,int,int)
{
btVector3 pt; // will be set to point of collision relative to body
- if(colObj0==body) {
+ if(colObj0->m_collisionObject==body) {
pt = cp.m_localPointA;
- ctxt->contactCallBack(colObj1);
+ ctxt->contactCallBack(colObj1->m_collisionObject);
} else {
- assert(colObj1==body && "body does not match either collision object");
+ Q_ASSERT_X(colObj1->m_collisionObject==body, "smellsensor", "body does not match either collision object");
pt = cp.m_localPointB;
- ctxt->contactCallBack(colObj0);
+ ctxt->contactCallBack(colObj0->m_collisionObject);
}
// do stuff with the collision point
return 0; // not actually sure if return value is used for anything...?
}
+
};
}
diff --git a/src/genecraft/core/experiment/experiment.cpp b/src/genecraft/core/experiment/experiment.cpp
index 3296f5c..2e45f64 100644
--- a/src/genecraft/core/experiment/experiment.cpp
+++ b/src/genecraft/core/experiment/experiment.cpp
@@ -47,7 +47,7 @@ Experiment::Experiment() : ressource(NULL){
mutationsManager = new MutationsManager();
// world
- worldDataMap = btWorldFactory::createSimpleWorld().toMap();
+ worldDataMap = btWorldFactory::createSimpleWorld();
// seed
seedInfo.insert("type", "family");
@@ -75,9 +75,8 @@ Experiment::Experiment() : ressource(NULL){
delete mutationsManager;
}
- Experiment::Experiment(QVariant data) : ressource(NULL) {
+ Experiment::Experiment(QJsonObject map) : ressource(NULL) {
- QVariantMap map = data.toMap();
online = false;
// TODO
@@ -102,13 +101,13 @@ Experiment::Experiment() : ressource(NULL){
stopIfEntityIsNotInOnePiece = map["stopIfEntityIsNotInOnePiece"].toBool();
// mutations
- mutationsManager = new MutationsManager(map["mutations"]);
+ mutationsManager = new MutationsManager(map["mutations"].toObject());
// world
- worldDataMap = map["world"].toMap();
+ worldDataMap = map["world"].toObject();
// seed TODO
- seedInfo = map["seedInfo"].toMap();
+ seedInfo = map["seedInfo"].toObject();
if(map.contains("evalFunction")) {
evalFunction = map["evalFunction"].toString();
@@ -163,8 +162,8 @@ Experiment::Experiment() : ressource(NULL){
}
}
- QVariant Experiment::serialize() {
- QVariantMap map;
+ QJsonObject Experiment::serialize() {
+ QJsonObject map;
// version
map.insert("version",EXP_FORMAT_VERSION);
diff --git a/src/genecraft/core/experiment/experiment.h b/src/genecraft/core/experiment/experiment.h
index 858e1d0..63882a6 100644
--- a/src/genecraft/core/experiment/experiment.h
+++ b/src/genecraft/core/experiment/experiment.h
@@ -23,7 +23,7 @@ along with Genecraft-Project. If not, see .
#include "result.h"
#include
#include
-#include
+#include
#include
#include "genecraftcoreclasses.h"
#include "bullet/btworld.h"
@@ -36,8 +36,8 @@ namespace GeneCraftCore {
Experiment();
~Experiment();
- Experiment(QVariant data);
- QVariant serialize();
+ Experiment(QJsonObject data);
+ QJsonObject serialize();
// -----------------
// -- Information --
@@ -114,15 +114,15 @@ namespace GeneCraftCore {
// -- World --
// -----------
- QVariantMap getWorldDataMap() { return worldDataMap; }
- void setWorldData(QVariantMap worldDataMap) { this->worldDataMap = worldDataMap; }
+ QJsonObject getWorldDataMap() { return worldDataMap; }
+ void setWorldData(QJsonObject worldDataMap) { this->worldDataMap = worldDataMap; }
// ----------
// -- Seed --
// ----------
- QVariantMap getSeedInfo() { return this->seedInfo; }
- void setSeedInfo(QVariantMap seedInfo) { this->seedInfo = seedInfo; }
+ QJsonObject getSeedInfo() { return this->seedInfo; }
+ void setSeedInfo(QJsonObject seedInfo) { this->seedInfo = seedInfo; }
// -----------
// -- Other --
@@ -162,10 +162,10 @@ namespace GeneCraftCore {
MutationsManager *mutationsManager;
// World
- QVariantMap worldDataMap;
+ QJsonObject worldDataMap;
// Seed
- QVariantMap seedInfo;
+ QJsonObject seedInfo;
QString evalFunction;
QString validityFunction;
diff --git a/src/genecraft/core/experiment/experimentmanager.cpp b/src/genecraft/core/experiment/experimentmanager.cpp
index 4cb26a9..48f952c 100644
--- a/src/genecraft/core/experiment/experimentmanager.cpp
+++ b/src/genecraft/core/experiment/experimentmanager.cpp
@@ -53,16 +53,15 @@ along with Genecraft-Project. If not, see .
#include "ressources/ressourcesmanager.h"
#include "tools.h"
-
-#include
-#include
+#include
+#include
namespace GeneCraftCore {
/**
* Creating an experiment manager for a given experiment
*/
- ExperimentManager::ExperimentManager(btFactory* factory, Experiment* exp, QVariant workerData) {
+ ExperimentManager::ExperimentManager(btFactory* factory, Experiment* exp, QJsonObject workerData) {
this->factory = factory;
this->exp = exp;
this->load(workerData);
@@ -71,7 +70,7 @@ namespace GeneCraftCore {
/**
* Creating an experiment manager for a giver experiment data
*/
- ExperimentManager::ExperimentManager(btFactory* factory, QVariant expData, QVariant workerData) {
+ ExperimentManager::ExperimentManager(btFactory* factory, QJsonObject expData, QJsonObject workerData) {
this->factory = factory;
this->exp = new Experiment(Ressource::load(expData));
this->load(workerData);
@@ -79,21 +78,20 @@ namespace GeneCraftCore {
//protected
- void ExperimentManager::load(QVariant workerData) {
- QVariantMap workerMap = workerData.toMap();
- this->maxGen = workerMap["maxGen"].toInt();
- this->popSize = workerMap["popSize"].toInt();
- this->workerName = workerMap["name"].toString();
+ void ExperimentManager::load(QJsonObject workerData) {
+ this->maxGen = workerData["maxGen"].toInt();
+ this->popSize = workerData["popSize"].toInt();
+ this->workerName = workerData["name"].toString();
- int bestResultsStored = workerMap["nbBestResults"].toInt();
- int randomResultsStored = workerMap["nbRandomResults"].toInt();
+ int bestResultsStored = workerData["nbBestResults"].toInt();
+ int randomResultsStored = workerData["nbRandomResults"].toInt();
- this->results = new ResultsManager(exp,bestResultsStored, randomResultsStored,workerName);
+ this->results = new ResultsManager(exp,bestResultsStored, randomResultsStored, workerName);
if(exp->isOnline()) {
this->ressources = new RessourcesManager(this->results->getDb(), QDir());
}
- QVariantMap selectionMap = workerMap["selection"].toMap();
+ QJsonObject selectionMap = workerData["selection"].toObject();
this->probFromBestsPop = selectionMap["bestPop"].toDouble();
this->probFromBestsResult = selectionMap["bestResult"].toDouble();
this->probFromRandomPop = selectionMap["randomPop"].toDouble();
@@ -121,7 +119,7 @@ namespace GeneCraftCore {
Statistic* stat = stats[statName];
// Insert a new properties of our top level object
// With the name of the statistic
- QScriptValue statObject = scriptEngine.newQObject(stat);
+ QJSValue statObject = scriptEngine.newQObject(stat);
entityObj.setProperty(statName, statObject);
}
@@ -274,9 +272,9 @@ namespace GeneCraftCore {
}
// A new entity
- QVariant ExperimentManager::randomNewEntity() {
+ QJsonObject ExperimentManager::randomNewEntity() {
// How to create the new entities ?
- QVariantMap seedInfo = exp->getSeedInfo();
+ QJsonObject seedInfo = exp->getSeedInfo();
QString type = seedInfo["type"].toString();
// From a family
if(type == "family") {
@@ -305,7 +303,7 @@ namespace GeneCraftCore {
Entity* e = GenericFamily::createVirginEntity(shapesFactory, Tools::random(0.2, 1.0), position);
e->setup();
e->setGeneration(0);
- QVariant genome = e->serialize();
+ QJsonObject genome = e->serialize();
// Tree starting mutations !
for(int i = 0; i < 3; i++)
genome = mutations->mutateEntity(genome);
@@ -318,7 +316,7 @@ namespace GeneCraftCore {
Entity* e = GenericFamily::createVirginEntity(shapesFactory, Tools::random(0.2, 1.0), position);
e->setup();
e->setGeneration(0);
- QVariant genome = e->serialize();
+ QJsonObject genome = e->serialize();
// Tree starting mutations !
for(int i = 0; i < 3; i++)
genome = mutations->mutateEntity(genome);
@@ -334,24 +332,24 @@ namespace GeneCraftCore {
e->setup();
e->setGeneration(0);
// Serialisation
- QVariant genome = e->serialize();
+ QJsonObject genome = e->serialize();
delete e;
delete family;
return genome;
} else if(type == "fixedGenomes") {
//qDebug() << "loading from fixed genome";
// TODO FIXME !
- static QVariantList genomes = QVariantList();
- if(genomes == QVariantList()) {
- QVariantList genomesInfo = seedInfo["genomes"].toList();
- foreach(QVariant genome, genomesInfo) {
- genomes.append(Ressource::load(genome));
+ static QJsonArray genomes = QJsonArray();
+ if(genomes == QJsonArray()) {
+ QJsonArray genomesInfo = seedInfo["genomes"].toArray();
+ foreach(QJsonValue genome, genomesInfo) {
+ genomes.append(Ressource::load(genome.toObject()));
}
}
int randomGen = qrand()%genomes.size();
- return mutations->mutateEntity(genomes.at(randomGen));
+ return mutations->mutateEntity(genomes.at(randomGen).toObject());
}
- return QVariant();
+ return QJsonObject();
}
/**
@@ -388,10 +386,10 @@ namespace GeneCraftCore {
// random new from results
int id = qrand()%max;
Result* r = results->getRandomResults().at(id);
- QVariant genome = r->getGenome();
+ QJsonObject genome = r->getGenome();
// Mutation
- QVariant newGenome = mutations->mutateEntity(genome);
+ QJsonObject newGenome = mutations->mutateEntity(genome);
qDebug() << (newGenome == genome);
// Adding to the active population
@@ -422,10 +420,10 @@ namespace GeneCraftCore {
// random new from results
int id = qrand()%max;
Result* r = activePop.at(id);
- QVariant genome = r->getGenome();
+ QJsonObject genome = r->getGenome();
// Mutation
- QVariant newGenome = mutations->mutateEntity(genome);
+ QJsonObject newGenome = mutations->mutateEntity(genome);
qDebug() << (newGenome == genome);
// Adding to the active population
@@ -436,7 +434,7 @@ namespace GeneCraftCore {
//Remaining random new
int needed = this->popSize - newActivePop.length();
for(int i = 0; i < needed; i++) {
- QVariant newGenome = this->randomNewEntity();
+ QJsonObject newGenome = this->randomNewEntity();
newActivePop.append(new Result(exp->getId(), 0, 0, 0, newGenome, workerName));
qDebug() << "new random genome from seeds !";
}
@@ -454,7 +452,7 @@ namespace GeneCraftCore {
// To avoid saving rounding problematic
// Could still append if the entity modified himself during or
// At the beginning of the simulation
- r->setGenome(QxtJSON::parse(QxtJSON::stringify(r->getGenome())));
+ r->setGenome(QJsonDocument::fromJson(QJsonDocument::fromVariant(r->getGenome()).toJson()).object());
qDebug() << "Evaluation of a specimen" << exp->getNbRun() << "times.";
for(int run = 0; run < exp->getNbRun(); run++) {
@@ -493,7 +491,7 @@ namespace GeneCraftCore {
// Store the statistics inside the result
QString stats = scriptEngine.evaluate("JSON.stringify(entity)").toString();
- r->setStatistics(QxtJSON::parse(stats));
+ r->setStatistics(QJsonDocument::fromJson(stats.toUtf8()).object());
// env pressure on genes
r->setGenome(e->serialize());
@@ -522,7 +520,7 @@ namespace GeneCraftCore {
// To simulate a specific entity
- Entity* ExperimentManager::spawnEntity(QVariant genome) {
+ Entity* ExperimentManager::spawnEntity(QJsonObject genome) {
delete world;
world = worldFactory->createWorld(factory, shapesFactory, exp->getWorldDataMap());
btVector3 position = world->getSpawnPosition();
@@ -554,7 +552,7 @@ namespace GeneCraftCore {
e->getShape()->getRoot()->setOutputsFrom(fromNormal); // Brain
this->engineStep();
- QScriptValue valid = this->validityFunc.call();
+ QJSValue valid = this->validityFunc.call();
if(!valid.toBool()) {
qDebug() << "user validity check fail";
return false;
@@ -610,13 +608,13 @@ namespace GeneCraftCore {
return false;
}
- QScriptValue died = dieFunc.call();
+ QJSValue died = dieFunc.call();
if(died.toBool()) {
qDebug() << "creature die (user function)";
return false;
}
- QScriptValue endV = endFunc.call(QScriptValue(), QScriptValueList() << i);
+ QJSValue endV = endFunc.call(QJSValueList() << i);
if(endV.toBool()) {
qDebug() << "end of simulation (user triggered)";
return true;
@@ -627,7 +625,7 @@ namespace GeneCraftCore {
btScalar ExperimentManager::evaluateEntity(Entity*) {
// Call to the fitness function
- QScriptValue fitness = fitnessFunc.call();
+ QJSValue fitness = fitnessFunc.call();
return fitness.toNumber();
}
diff --git a/src/genecraft/core/experiment/experimentmanager.h b/src/genecraft/core/experiment/experimentmanager.h
index 1d086ce..76156cb 100644
--- a/src/genecraft/core/experiment/experimentmanager.h
+++ b/src/genecraft/core/experiment/experimentmanager.h
@@ -24,8 +24,8 @@ along with Genecraft-Project. If not, see .
#include "experiment.h"
#include "resultsmanager.h"
#include "mutation/mutationsmanager.h"
-
-#include
+#include
+#include
class SelectionManager;
@@ -36,12 +36,12 @@ namespace GeneCraftCore {
/**
* Creating an experiment manager for a given experiment
*/
- ExperimentManager(btFactory* factory, Experiment* exp, QVariant workerData) ;
+ ExperimentManager(btFactory* factory, Experiment* exp, QJsonObject workerData) ;
/**
* Creating an experiment manager for a giver experiment data
*/
- ExperimentManager(btFactory* factory, QVariant expData, QVariant workerData);
+ ExperimentManager(btFactory* factory, QJsonObject expData, QJsonObject workerData);
/**
* Experimentation loop
@@ -76,14 +76,14 @@ namespace GeneCraftCore {
protected:
// To simulate a specific entity
- Entity* spawnEntity(QVariant genome);
+ Entity* spawnEntity(QJsonObject genome);
bool stabilizeEntity(Entity* e, Result* r);
bool simulateEntity(Entity* e);
btScalar evaluateEntity(Entity* e);
void engineStep();
- QVariant randomNewEntity();
+ QJsonObject randomNewEntity();
- void load(QVariant data);
+ void load(QJsonObject data);
void createEngine();
void bindEntity(Entity* e);
@@ -105,12 +105,12 @@ namespace GeneCraftCore {
QMap engines;
// Scripting
- QScriptEngine scriptEngine;
- QScriptValue entityObj;
- QScriptValue validityFunc;
- QScriptValue endFunc;
- QScriptValue dieFunc;
- QScriptValue fitnessFunc;
+ QJSEngine scriptEngine;
+ QJSValue entityObj;
+ QJSValue validityFunc;
+ QJSValue endFunc;
+ QJSValue dieFunc;
+ QJSValue fitnessFunc;
int maxGen;
int popSize;
diff --git a/src/genecraft/core/experiment/result.cpp b/src/genecraft/core/experiment/result.cpp
index 8e91072..6705e66 100644
--- a/src/genecraft/core/experiment/result.cpp
+++ b/src/genecraft/core/experiment/result.cpp
@@ -22,8 +22,6 @@ along with Genecraft-Project. If not, see .
#include
#include
-#include
-
namespace GeneCraftCore {
// To sort result, descending
@@ -41,9 +39,9 @@ namespace GeneCraftCore {
ressource->save(this->serialize());
}
- QVariant Result::serialize() {
+ QJsonObject Result::serialize() {
- QVariantMap resultData;
+ QJsonObject resultData;
resultData.insert("type", "result");
resultData.insert("experiment", exp);
resultData.insert("fitness", (double)this->fitness);
@@ -64,10 +62,10 @@ namespace GeneCraftCore {
this->ressource = NULL;
this->exp = "";
this->date = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
- this->genome = QVariant();
+ this->genome = QJsonObject();
this->worker = "";
this->broadcasted = false;
- this->statistics = QVariant();
+ this->statistics = QJsonObject();
this->stableTime = 0;
this->nbRun = 0;
}
@@ -81,7 +79,7 @@ namespace GeneCraftCore {
* A result is a fitness for a genome, and the ressource where this result is stored
* If it come from a parent result (mutation, etc..) the ressource of the parent is attached
*/
- Result::Result(QString expId, btScalar fitness, int nbRun, int stableTime, QVariant genome,
+ Result::Result(QString expId, btScalar fitness, int nbRun, int stableTime, QJsonObject genome,
QString worker, QString date) {
this->exp = expId;
if(nbRun == 0) {
@@ -97,7 +95,7 @@ namespace GeneCraftCore {
this->date = date;
this->worker = worker;
this->broadcasted = false;
- this->statistics = QVariant();
+ this->statistics = QJsonObject();
this->stableTime = stableTime;
}
@@ -134,61 +132,59 @@ namespace GeneCraftCore {
this->nbRun = r.nbRun;
}
- Result* Result::loadResult(QVariant data, bool& ok) {
+ Result* Result::loadResult(QJsonObject data, bool& ok) {
ok = true;
- QVariantMap dataMap = data.toMap();
- btScalar fitness = dataMap["fitness"].toFloat(&ok);
- if(!ok)
+ if(!data.contains("fitness")) {
return new Result();
+ }
+ btScalar fitness = data["fitness"].toDouble();
- if(!dataMap.contains("genome")) {
+ if(!data.contains("genome")) {
ok = false;
return new Result();
}
+ QJsonObject genome = data["genome"].toObject();
- if(!dataMap.contains("experiment")) {
+ if(!data.contains("experiment")) {
ok = false;
return new Result();
}
- if(!dataMap.contains("date")) {
+ QString exp = data["experiment"].toString();
+ if(!data.contains("date")) {
ok = false;
return new Result();
}
+ QString date = data["date"].toString();
QString worker;
- if(!dataMap.contains("worker")) {
+ if(!data.contains("worker")) {
worker = "OldResult";
} else {
- worker = dataMap["worker"].toString();
+ worker = data["worker"].toString();
}
- QVariant statistics = QVariant();
- if(dataMap.contains("statistics")) {
- statistics = dataMap["statistics"];
+ QJsonObject statistics = QJsonObject();
+ if(data.contains("statistics")) {
+ statistics = data["statistics"].toObject();
}
int stableTime = 0;
- if(dataMap.contains("stable")) {
- stableTime = dataMap["stable"].toInt();
+ if(data.contains("stable")) {
+ stableTime = data["stable"].toInt();
}
int nbRun = 1;
- if(dataMap.contains("nbRun")) {
- nbRun = dataMap["nbRun"].toInt();
+ if(data.contains("nbRun")) {
+ nbRun = data["nbRun"].toInt();
}
- QVariantMap genome = dataMap["genome"].toMap();
- QString exp = dataMap["experiment"].toString();
- QString date = dataMap["date"].toString();
Result* r = new Result(exp, fitness, nbRun, stableTime, genome, worker, date);
r->setStatistics(statistics);
-
-
return r;
}
}
diff --git a/src/genecraft/core/experiment/result.h b/src/genecraft/core/experiment/result.h
index 74dc5a2..7d46544 100644
--- a/src/genecraft/core/experiment/result.h
+++ b/src/genecraft/core/experiment/result.h
@@ -21,7 +21,7 @@ along with Genecraft-Project. If not, see .
#define RESULT_H
#include "factories/ressources/ressource.h"
-#include
+#include
#include
#include "LinearMath/btScalar.h"
@@ -40,7 +40,7 @@ namespace GeneCraftCore {
* A result is a fitness for a genome, and the ressource where this result is stored
* If it come from a parent result (mutation, etc..) the ressource of the parent is attached
*/
- Result(QString expId, btScalar fitness, int nbRun, int stableTime, QVariant genome,
+ Result(QString expId, btScalar fitness, int nbRun, int stableTime, QJsonObject genome,
QString workerName = "Anonymous",
QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")
);
@@ -66,9 +66,9 @@ namespace GeneCraftCore {
* Broadcast a result -> save it to the ressource
*/
void save(Ressource * r);
- QVariant serialize();
+ QJsonObject serialize();
- static Result* loadResult(QVariant data, bool& ok);
+ static Result* loadResult(QJsonObject data, bool& ok);
btScalar getFitness() const {
if(nbRun > 0)
@@ -77,7 +77,7 @@ namespace GeneCraftCore {
return -1;
}
- QVariant getGenome() const {
+ QJsonObject getGenome() const {
return genome;
}
@@ -98,7 +98,7 @@ namespace GeneCraftCore {
this->fitness += fitness;
}
- void setGenome(QVariant genome) {
+ void setGenome(QJsonObject genome) {
this->genome = genome;
}
@@ -126,11 +126,11 @@ namespace GeneCraftCore {
return this->broadcasted;
}
- void setStatistics(QVariant statistics) {
+ void setStatistics(QJsonObject statistics) {
this->statistics = statistics;
}
- QVariant getStatistics() {
+ QJsonObject getStatistics() {
return this->statistics;
}
@@ -163,7 +163,7 @@ namespace GeneCraftCore {
// Score
btScalar fitness;
// Entity
- QVariant genome;
+ QJsonObject genome;
// Where to store it
Ressource* ressource;
// The attached experimentation
@@ -175,7 +175,7 @@ namespace GeneCraftCore {
// Broadcasted online already ?
bool broadcasted;
// The entity statistics
- QVariant statistics;
+ QJsonObject statistics;
// Stability reached at
int stableTime;
// Nb Time tested
diff --git a/src/genecraft/core/experiment/resultsmanager.cpp b/src/genecraft/core/experiment/resultsmanager.cpp
index 3a4463e..a9cd58d 100644
--- a/src/genecraft/core/experiment/resultsmanager.cpp
+++ b/src/genecraft/core/experiment/resultsmanager.cpp
@@ -21,6 +21,8 @@ along with Genecraft-Project. If not, see .
#include "ressources/jsonfile.h"
#include "ressources/dbrecord.h"
+#include
+
#define RESULTS_DIR "results"
namespace GeneCraftCore {
@@ -102,7 +104,7 @@ namespace GeneCraftCore {
= qMax(lastModifiedResultLoaded, fileInfo.lastModified());
JsonFile* file = new JsonFile(results.absoluteFilePath(f));
- QVariant result = file->load();
+ QJsonObject result = file->load();
bool valid = false;
Result* r = Result::loadResult(result, valid);
r->setRessource(file);
@@ -145,7 +147,7 @@ namespace GeneCraftCore {
}
JsonFile* file = new JsonFile(results.absoluteFilePath(f));
- QVariant result = file->load();
+ QJsonObject result = file->load();
bool valid = false;
Result* r = Result::loadResult(result, valid);
r->setRessource(file);
@@ -173,19 +175,18 @@ namespace GeneCraftCore {
QString::number(qMax(this->randomResultsStored, this->bestResultsStored))
+"&descending=true";
DbRecord* r = new DbRecord(db, id);
- QVariant data = r->load();
+ QJsonObject results = r->load();
delete r;
- QVariantMap results = data.toMap();
- QVariantList rows = results["rows"].toList();
- QVariantList ids;
- foreach(QVariant row, rows) {
+ QJsonArray rows = results["rows"].toArray();
+ QJsonArray ids;
+ foreach(QJsonValue row, rows) {
QString id;
- if( row.toMap()["value"].toList().length() == 2) {
- id = row.toMap()["value"].toList()[1].toList()[1].toString();
+ if( row.toObject()["value"].toArray().count() == 2) {
+ id = row.toObject()["value"].toArray()[1].toArray()[1].toString();
} else {
- id = row.toMap()["value"].toList()[4].toString();
+ id = row.toObject()["value"].toArray()[4].toString();
}
if(id.left(14) > lastLoadedId.left(14)) {
@@ -194,16 +195,15 @@ namespace GeneCraftCore {
ids.append(id);
}
- QVariantMap postData;
+ QJsonObject postData = QJsonObject();
postData.insert("keys", ids);
Ressource* re = new DbRecord(db, "_all_docs?include_docs=true", postData);
- QVariant genomes = re->load();
+ QJsonObject genomesMap = re->load();
- QVariantMap genomesMap = genomes.toMap();
- QVariantList genomesList = genomesMap["rows"].toList();
+ QJsonArray genomesList = genomesMap["rows"].toArray();
- foreach(QVariant genomeResult, genomesList) {
- QVariant genome = genomeResult.toMap()["doc"];
+ foreach(QJsonValue genomeResult, genomesList) {
+ QJsonObject genome = genomeResult.toObject()["doc"].toObject();
bool valid;
Result* result = Result::loadResult(genome, valid);
if(valid) {
@@ -227,20 +227,19 @@ namespace GeneCraftCore {
QString::number(qMax(this->randomResultsStored, this->bestResultsStored))
+"&descending=true";
DbRecord* r = new DbRecord(db, id);
- QVariant data = r->load();
+ QJsonObject results = r->load();
delete r;
- QVariantMap results = data.toMap();
- QVariantList rows = results["rows"].toList();
+ QJsonArray rows = results["rows"].toArray();
QString newLastLoadedId = lastLoadedId;
- QVariantList ids;
- foreach(QVariant row, rows) {
+ QJsonArray ids;
+ foreach(QJsonValue row, rows) {
QString id;
- if(row.toMap()["value"].toList().length() == 2) {
- id = row.toMap()["value"].toList()[1].toList()[1].toString();
+ if(row.toObject()["value"].toArray().count() == 2) {
+ id = row.toObject()["value"].toArray()[1].toArray()[1].toString();
} else {
- id = row.toMap()["value"].toList()[4].toString();
+ id = row.toObject()["value"].toArray()[4].toString();
}
if(id.left(14) <= lastLoadedId.left(14)) {
@@ -253,16 +252,15 @@ namespace GeneCraftCore {
ids.append(id);
}
- QVariantMap postData;
+ QJsonObject postData;
postData.insert("keys", ids);
Ressource* re = new DbRecord(db, "_all_docs?include_docs=true", postData);
- QVariant genomes = re->load();
+ QJsonObject genomesMap = re->load();
- QVariantMap genomesMap = genomes.toMap();
- QVariantList genomesList = genomesMap["rows"].toList();
+ QJsonArray genomesList = genomesMap["rows"].toArray();
- foreach(QVariant genomeResult, genomesList) {
- QVariant genome = genomeResult.toMap()["doc"];
+ foreach(QJsonValue genomeResult, genomesList) {
+ QJsonObject genome = genomeResult.toObject()["doc"].toObject();
bool valid;
Result* result = Result::loadResult(genome, valid);
if(valid && result->getWorker() != this->workerName) {
@@ -284,7 +282,7 @@ namespace GeneCraftCore {
* To save the actual progression of the experiment
*/
void ResultsManager::save() {
- QVariantList docsList;
+ QJsonArray docsList;
foreach(Result* r, bestResults) {
if(r->getFitness() > 0.0 && !r->isBroadcasted()) {
@@ -305,7 +303,7 @@ namespace GeneCraftCore {
}
if(online) {
- QVariantMap postData;
+ QJsonObject postData;
postData.insert("docs", docsList);
DbRecord* r = new DbRecord(db, "_bulk_docs");
r->save(postData);
@@ -325,10 +323,10 @@ namespace GeneCraftCore {
foreach(Result * r, bestResults) {
if(r->getFitness() + 0.0001 > result->getFitness() &&
r->getFitness() - 0.0001 < result->getFitness()) {
- QVariantMap g1 = r->getGenome().toMap();
- g1.insert("origins", QVariant());
- QVariantMap g2 = result->getGenome().toMap();
- g2.insert("origins", QVariant());
+ QJsonObject g1 = r->getGenome();
+ g1.insert("origins", QJsonObject());
+ QJsonObject g2 = result->getGenome();
+ g2.insert("origins", QJsonObject());
// Check if genome is the same
if(g1 == g2) {
already = true;
diff --git a/src/genecraft/core/factories/base/creaturefactory.cpp b/src/genecraft/core/factories/base/creaturefactory.cpp
index 9c6d435..e562e4c 100644
--- a/src/genecraft/core/factories/base/creaturefactory.cpp
+++ b/src/genecraft/core/factories/base/creaturefactory.cpp
@@ -23,16 +23,15 @@ along with Genecraft-Project. If not, see .
namespace GeneCraftCore {
- Entity* CreatureFactory::createEntity(QVariant data,
+ Entity* CreatureFactory::createEntity(QJsonObject entityData,
btShapesFactory* shapesFactory,
btVector3 position) {
- QVariantMap entityData = data.toMap();
// inside a result ?
if(entityData["type"].toString() == "result") {
// Decapsulate
qDebug() << "decapsulation from result !";
- entityData = entityData["genome"].toMap();
+ entityData = entityData["genome"].toObject();
}
// Version check
diff --git a/src/genecraft/core/factories/base/creaturefactory.h b/src/genecraft/core/factories/base/creaturefactory.h
index 48b14f1..3f55b98 100644
--- a/src/genecraft/core/factories/base/creaturefactory.h
+++ b/src/genecraft/core/factories/base/creaturefactory.h
@@ -30,7 +30,7 @@ namespace GeneCraftCore {
public:
- static Entity* createEntity(QVariant data,
+ static Entity* createEntity(QJsonObject data,
btShapesFactory* shapesFactory,
btVector3 positionSensor);
};
diff --git a/src/genecraft/core/factories/bullet/btshapesfactory.cpp b/src/genecraft/core/factories/bullet/btshapesfactory.cpp
index 48c6b66..131f8a9 100644
--- a/src/genecraft/core/factories/bullet/btshapesfactory.cpp
+++ b/src/genecraft/core/factories/bullet/btshapesfactory.cpp
@@ -30,22 +30,22 @@ btShapesFactory::btShapesFactory()
{
}
-btBox *btShapesFactory::createBox(btVector3 size, const btTransform &transform, const btScalar density, QVariant)
+btBox *btShapesFactory::createBox(btVector3 size, const btTransform &transform, const btScalar density, QJsonObject)
{
return new btBox(world, size, transform, density);
}
-btSphere *btShapesFactory::createSphere(btScalar radius, const btTransform &transform, const btScalar density, QVariant)
+btSphere *btShapesFactory::createSphere(btScalar radius, const btTransform &transform, const btScalar density, QJsonObject)
{
return new btSphere(world, radius, transform, density);
}
-btCylinder *btShapesFactory::createCylinder(btScalar radius, btScalar height, const btTransform &transform, const btScalar density, QVariant)
+btCylinder *btShapesFactory::createCylinder(btScalar radius, btScalar height, const btTransform &transform, const btScalar density, QJsonObject)
{
return new btCylinder(world, radius, height, transform, density);
}
-btBone* btShapesFactory::createBone(btScalar length, btScalar radius, btScalar radiusArticulation, const btTransform &transform, QVariant) {
+btBone* btShapesFactory::createBone(btScalar length, btScalar radius, btScalar radiusArticulation, const btTransform &transform, QJsonObject) {
return new btBone(world, length, radius, radiusArticulation, transform);
}
diff --git a/src/genecraft/core/factories/bullet/btshapesfactory.h b/src/genecraft/core/factories/bullet/btshapesfactory.h
index 5a1976b..0f8496e 100644
--- a/src/genecraft/core/factories/bullet/btshapesfactory.h
+++ b/src/genecraft/core/factories/bullet/btshapesfactory.h
@@ -22,7 +22,7 @@ along with Genecraft-Project. If not, see .
#include "genecraftcoreclasses.h"
#include "LinearMath/btTransform.h"
-#include "QVariant"
+#include
namespace GeneCraftCore {
@@ -39,10 +39,10 @@ class btShapesFactory
virtual void setWorld(btWorld* world) { this->world = world; }
- virtual btBox *createBox(btVector3 size, const btTransform &transform, const btScalar density, QVariant params = QVariant());
- virtual btSphere *createSphere(btScalar radius, const btTransform &transform, const btScalar density, QVariant params = QVariant());
- virtual btCylinder *createCylinder(btScalar radius, btScalar height, const btTransform &transform, const btScalar density, QVariant params = QVariant());
- virtual btBone *createBone(btScalar length, btScalar radius, btScalar radiusArticulation, const btTransform &transform, QVariant params = QVariant());
+ virtual btBox *createBox(btVector3 size, const btTransform &transform, const btScalar density, QJsonObject params = QJsonObject());
+ virtual btSphere *createSphere(btScalar radius, const btTransform &transform, const btScalar density, QJsonObject params = QJsonObject());
+ virtual btCylinder *createCylinder(btScalar radius, btScalar height, const btTransform &transform, const btScalar density, QJsonObject params = QJsonObject());
+ virtual btBone *createBone(btScalar length, btScalar radius, btScalar radiusArticulation, const btTransform &transform, QJsonObject params = QJsonObject());
protected:
btWorld* world;
diff --git a/src/genecraft/core/factories/bullet/btworldfactory.cpp b/src/genecraft/core/factories/bullet/btworldfactory.cpp
index 3c6c7d2..bb02518 100644
--- a/src/genecraft/core/factories/bullet/btworldfactory.cpp
+++ b/src/genecraft/core/factories/bullet/btworldfactory.cpp
@@ -22,27 +22,28 @@ along with Genecraft-Project. If not, see .
#include "tools.h"
#include
+#include
namespace GeneCraftCore {
- QVariant btWorldFactory::createSimpleWorld() {
+ QJsonObject btWorldFactory::createSimpleWorld() {
// World from program (soon from file)
- QVariantMap worldData;
+ QJsonObject worldData;
worldData.insert("name", "Somewhere on Earth");
// ------------
// -- Biome --
// ------------
- QVariantMap biomeData;
+ QJsonObject biomeData;
biomeData.insert("gravity", 9.81);
biomeData.insert("skyMaterial", "Examples/CloudySky");
// -- lights --
- QVariantList lights;
+ QJsonArray lights;
// ambiant
- QVariantMap ambiantLightMap;
+ QJsonObject ambiantLightMap;
ambiantLightMap.insert("type","ambient");
ambiantLightMap.insert("r",(double)0.8);
ambiantLightMap.insert("g",(double)0.8);
@@ -50,7 +51,7 @@ namespace GeneCraftCore {
lights.append(ambiantLightMap);
// point
- QVariantMap pointLightMap;
+ QJsonObject pointLightMap;
pointLightMap.insert("type","point");
pointLightMap.insert("r",(double)1.);
pointLightMap.insert("g",(double)1.);
@@ -61,7 +62,7 @@ namespace GeneCraftCore {
lights.append(pointLightMap);
// directional
-// QVariantMap directionalLightMap;
+// QJsonObject directionalLightMap;
// directionalLightMap.insert("type","directional");
// directionalLightMap.insert("r",(double)1.0);
// directionalLightMap.insert("g",(double)1.0);
@@ -80,10 +81,10 @@ namespace GeneCraftCore {
// -----------
// -- Scene --
// -----------
- QVariantMap sceneData;
+ QJsonObject sceneData;
// -- Camera --
- QVariantMap camData;
+ QJsonObject camData;
camData.insert("posX", -20);
camData.insert("posY", 10);
camData.insert("posZ", -20);
@@ -93,12 +94,12 @@ namespace GeneCraftCore {
sceneData.insert("camera", camData);
// -- Spawn areas --
- QVariantList spawns;
+ QJsonArray spawns;
//createBoxAreaSpawn(spawns,btVector3(100,1,100),btVector3(0,20,0));
createPositionSpawn(spawns,btVector3(0,10,0));
-// QVariantMap zoneSpawn;
+// QJsonObject zoneSpawn;
// zoneSpawn.insert("type", (int)Spawn::Zone);
// zoneSpawn.insert("minX", -60);
// zoneSpawn.insert("minY", 10);
@@ -111,7 +112,7 @@ namespace GeneCraftCore {
sceneData.insert("spawns", spawns);
// -- Static boxes --
- QVariantList shapes;
+ QJsonArray shapes;
// createRuins(shapes, 100.0, 100.0, btVector3(0,0,0), btVector3(1.0,1.0,1.0), btVector3(10.0,10.0,10.0), 100, 0);
// createBoxesFloor(shapes, 100.0, 100.0, btVector3(0,0,0), btVector3(2.0,1.0,2.0), btVector3(15.0,2.0,15.0));
@@ -136,7 +137,7 @@ namespace GeneCraftCore {
sceneData.insert("shapes", shapes);
// Floor
- QVariantMap floor;
+ QJsonObject floor;
floor.insert("type", "flatland");
floor.insert("material", "GeneCraft/GrassFloor");
sceneData.insert("floor",floor);
@@ -146,9 +147,9 @@ namespace GeneCraftCore {
return worldData;
}
- void btWorldFactory::createPositionSpawn(QVariantList &spawnsList,btVector3 pos) {
+ void btWorldFactory::createPositionSpawn(QJsonArray &spawnsList,btVector3 pos) {
- QVariantMap positionSpawn;
+ QJsonObject positionSpawn;
positionSpawn.insert("type", "position");
positionSpawn.insert("posX", (double)pos.x());
positionSpawn.insert("posY", (double)pos.y());
@@ -156,9 +157,9 @@ namespace GeneCraftCore {
spawnsList.append(positionSpawn);
}
- void btWorldFactory::createBoxAreaSpawn(QVariantList &spawnsList, btVector3 size, btVector3 pos)
+ void btWorldFactory::createBoxAreaSpawn(QJsonArray &spawnsList, btVector3 size, btVector3 pos)
{
- QVariantMap spawnMap;
+ QJsonObject spawnMap;
spawnMap.insert("type", "boxArea");
spawnMap.insert("sizeX", (double)size.x());
spawnMap.insert("sizeY", (double)size.y());
@@ -169,9 +170,9 @@ namespace GeneCraftCore {
spawnsList.append(spawnMap);
}
- void btWorldFactory::createBox(QVariantList &shapesList, btVector3 size, btVector3 pos, btVector3 euler, double density)
+ void btWorldFactory::createBox(QJsonArray &shapesList, btVector3 size, btVector3 pos, btVector3 euler, double density)
{
- QVariantMap boxMap;
+ QJsonObject boxMap;
boxMap.insert("type","box");
boxMap.insert("density",(double)density);
boxMap.insert("posX",(double)pos.x());
@@ -186,9 +187,9 @@ namespace GeneCraftCore {
shapesList.append(boxMap);
}
- void btWorldFactory::createSphere(QVariantList &shapesList, btScalar radius, btVector3 pos, btVector3 euler, double density) {
+ void btWorldFactory::createSphere(QJsonArray &shapesList, btScalar radius, btVector3 pos, btVector3 euler, double density) {
- QVariantMap sphereMap;
+ QJsonObject sphereMap;
sphereMap.insert("type","sphere");
sphereMap.insert("radius",(double)radius);
sphereMap.insert("posX",(double)pos.x());
@@ -201,9 +202,9 @@ namespace GeneCraftCore {
shapesList.append(sphereMap);
}
- void btWorldFactory::createCylinder(QVariantList &shapesList, btScalar radius, btScalar height, btVector3 pos, btVector3 euler, double density) {
+ void btWorldFactory::createCylinder(QJsonArray &shapesList, btScalar radius, btScalar height, btVector3 pos, btVector3 euler, double density) {
- QVariantMap cylinderMap;
+ QJsonObject cylinderMap;
cylinderMap.insert("type","cylinder");
cylinderMap.insert("radius",(double)radius);
cylinderMap.insert("height",(double)height);
@@ -217,7 +218,7 @@ namespace GeneCraftCore {
shapesList.append(cylinderMap);
}
- void btWorldFactory::createBoxesStairs(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, double stepWidth, double yMinStep, double yMaxStep) {
+ void btWorldFactory::createBoxesStairs(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, double stepWidth, double yMinStep, double yMaxStep) {
// Boxes Floor
double sizeX = stepWidth;
@@ -243,7 +244,7 @@ namespace GeneCraftCore {
}
}
- void btWorldFactory::createSlope(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 axis, double minAngle, double maxAngle) {
+ void btWorldFactory::createSlope(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 axis, double minAngle, double maxAngle) {
@@ -254,7 +255,7 @@ namespace GeneCraftCore {
}
- void btWorldFactory::createBoxesFloor(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 boxMin, btVector3 boxMax) {
+ void btWorldFactory::createBoxesFloor(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 boxMin, btVector3 boxMax) {
// Boxes Floor
double sizeX = Tools::random((double)boxMin.x(), (double)boxMax.x());
@@ -279,7 +280,7 @@ namespace GeneCraftCore {
}
}
- void btWorldFactory::createRuins(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 boxMin, btVector3 boxMax, int nbBoxes, double density) {
+ void btWorldFactory::createRuins(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 boxMin, btVector3 boxMax, int nbBoxes, double density) {
// Ruin Floor
for(int i=0;isetWorld(world);
- btBiome* biome = new btBiome(world, worldMap["biome"]);
+ btBiome* biome = new btBiome(world, worldMap["biome"].toObject());
world->setBiome(biome);
- btScene* scene = new btScene(world, worldMap["scene"]);
+ btScene* scene = new btScene(world, worldMap["scene"].toObject());
world->setScene(scene);
world->setup();
@@ -320,7 +320,7 @@ namespace GeneCraftCore {
return world;
}
- void btWorldFactory::createPoolOfBalls(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, int nbBalls) {
+ void btWorldFactory::createPoolOfBalls(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, int nbBalls) {
// walls
btScalar wallsHeight = 10.0;
diff --git a/src/genecraft/core/factories/bullet/btworldfactory.h b/src/genecraft/core/factories/bullet/btworldfactory.h
index 4c27b7b..e2dec55 100644
--- a/src/genecraft/core/factories/bullet/btworldfactory.h
+++ b/src/genecraft/core/factories/bullet/btworldfactory.h
@@ -29,27 +29,27 @@ namespace GeneCraftCore {
public:
- static QVariant createSimpleWorld();
+ static QJsonObject createSimpleWorld();
static btWorld* createWorld( btFactory* factory,
btShapesFactory* shapesFactory,
- QVariant worldData);
+ QJsonObject worldData);
// spawns
- static void createPositionSpawn(QVariantList &spawns,btVector3 pos);
- static void createBoxAreaSpawn(QVariantList &spawnsList, btVector3 size, btVector3 pos);
+ static void createPositionSpawn(QJsonArray &spawns,btVector3 pos);
+ static void createBoxAreaSpawn(QJsonArray &spawnsList, btVector3 size, btVector3 pos);
// shapes
- static void createBox(QVariantList &shapesList, btVector3 size, btVector3 pos, btVector3 euler, double density);
- static void createSphere(QVariantList &shapesList, btScalar radius, btVector3 pos, btVector3 euler, double density);
- static void createCylinder(QVariantList &shapesList, btScalar radius, btScalar height, btVector3 pos, btVector3 euler, double density);
+ static void createBox(QJsonArray &shapesList, btVector3 size, btVector3 pos, btVector3 euler, double density);
+ static void createSphere(QJsonArray &shapesList, btScalar radius, btVector3 pos, btVector3 euler, double density);
+ static void createCylinder(QJsonArray &shapesList, btScalar radius, btScalar height, btVector3 pos, btVector3 euler, double density);
// floors
- static void createRuins(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 boxMin, btVector3 boxMax, int nbBoxes, double density = 0);
- static void createBoxesFloor(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 boxMin, btVector3 boxMax);
- static void createBoxesStairs(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, double stepWidth, double yMinStep, double yMaxStep);
- static void createSlope(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 axis, double minAngle, double maxAngle);
+ static void createRuins(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 boxMin, btVector3 boxMax, int nbBoxes, double density = 0);
+ static void createBoxesFloor(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 boxMin, btVector3 boxMax);
+ static void createBoxesStairs(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, double stepWidth, double yMinStep, double yMaxStep);
+ static void createSlope(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, btVector3 axis, double minAngle, double maxAngle);
// sphere pool
- static void createPoolOfBalls(QVariantList &shapesList, double areaX, double areaZ, btVector3 pos, int nbBalls);
+ static void createPoolOfBalls(QJsonArray &shapesList, double areaX, double areaZ, btVector3 pos, int nbBalls);
};
}
diff --git a/src/genecraft/core/factories/bulletogre/btoshapesfactory.cpp b/src/genecraft/core/factories/bulletogre/btoshapesfactory.cpp
index 4eea43a..e2a750b 100644
--- a/src/genecraft/core/factories/bulletogre/btoshapesfactory.cpp
+++ b/src/genecraft/core/factories/bulletogre/btoshapesfactory.cpp
@@ -36,22 +36,22 @@ btoShapesFactory::btoShapesFactory(BulletOgreEngine *btoEngine) : btShapesFactor
this->btoEngine = btoEngine;
}
-btBox *btoShapesFactory::createBox(btVector3 size, const btTransform &transform, const btScalar density, QVariant)
+btBox *btoShapesFactory::createBox(btVector3 size, const btTransform &transform, const btScalar density, QJsonObject)
{
return new btoBox((btoWorld*)world, btoEngine, size, transform, density);
}
-btSphere *btoShapesFactory::createSphere(btScalar radius, const btTransform &transform, const btScalar density, QVariant params)
+btSphere *btoShapesFactory::createSphere(btScalar radius, const btTransform &transform, const btScalar density, QJsonObject params)
{
return new btoSphere((btoWorld*)world, btoEngine, radius, transform, density, params);
}
-btCylinder *btoShapesFactory::createCylinder(btScalar radius, btScalar height, const btTransform &transform, const btScalar density, QVariant)
+btCylinder *btoShapesFactory::createCylinder(btScalar radius, btScalar height, const btTransform &transform, const btScalar density, QJsonObject)
{
return new btoCylinder((btoWorld*)world, btoEngine, radius, height, transform, density);
}
-btBone* btoShapesFactory::createBone(btScalar length, btScalar radius, btScalar radiusArticulation, const btTransform &transform, QVariant) {
+btBone* btoShapesFactory::createBone(btScalar length, btScalar radius, btScalar radiusArticulation, const btTransform &transform, QJsonObject) {
return new btoBone((btoWorld*)world, btoEngine, length, radius, radiusArticulation, transform);
}
diff --git a/src/genecraft/core/factories/bulletogre/btoshapesfactory.h b/src/genecraft/core/factories/bulletogre/btoshapesfactory.h
index 3718c52..41dc807 100644
--- a/src/genecraft/core/factories/bulletogre/btoshapesfactory.h
+++ b/src/genecraft/core/factories/bulletogre/btoshapesfactory.h
@@ -33,10 +33,10 @@ class btoShapesFactory : public btShapesFactory
virtual void setWorld(btoWorld* world) { this->world = world; }
- virtual btBox *createBox(btVector3 size, const btTransform &transform, const btScalar density, QVariant params = QVariant());
- virtual btSphere *createSphere(btScalar radius, const btTransform &transform, const btScalar density, QVariant params = QVariant());
- virtual btCylinder *createCylinder(btScalar radius, btScalar height, const btTransform &transform, const btScalar density, QVariant params = QVariant());
- virtual btBone *createBone(btScalar length, btScalar radius, btScalar radiusArticulation, const btTransform &transform, QVariant params = QVariant());
+ virtual btBox *createBox(btVector3 size, const btTransform &transform, const btScalar density, QJsonObject params = QJsonObject());
+ virtual btSphere *createSphere(btScalar radius, const btTransform &transform, const btScalar density, QJsonObject params = QJsonObject());
+ virtual btCylinder *createCylinder(btScalar radius, btScalar height, const btTransform &transform, const btScalar density, QJsonObject params = QJsonObject());
+ virtual btBone *createBone(btScalar length, btScalar radius, btScalar radiusArticulation, const btTransform &transform, QJsonObject params = QJsonObject());
protected:
BulletOgreEngine *btoEngine;
};
diff --git a/src/genecraft/core/factories/bulletogre/btoworldfactory.cpp b/src/genecraft/core/factories/bulletogre/btoworldfactory.cpp
index 320d16f..b46a2d2 100644
--- a/src/genecraft/core/factories/bulletogre/btoworldfactory.cpp
+++ b/src/genecraft/core/factories/bulletogre/btoworldfactory.cpp
@@ -29,17 +29,16 @@ namespace GeneCraftCore {
btoWorld* btoWorldFactory::createWorld(btoFactory *factory,
btoShapesFactory *shapesFactory,
- QVariant map) {
- QVariantMap worldMap = map.toMap();
+ QJsonObject worldMap) {
// Create the world
- btoWorld* world = new btoWorld(factory, shapesFactory, worldMap["world"]);
+ btoWorld* world = new btoWorld(factory, shapesFactory, worldMap["world"].toObject());
shapesFactory->setWorld(world);
- btBiome* biome = new btoBiome(world, worldMap["biome"]);
+ btBiome* biome = new btoBiome(world, worldMap["biome"].toObject());
world->setBiome(biome);
- btScene* scene = new btoScene(world, worldMap["scene"]);
+ btScene* scene = new btoScene(world, worldMap["scene"].toObject());
world->setScene(scene);
world->setup();
diff --git a/src/genecraft/core/factories/bulletogre/btoworldfactory.h b/src/genecraft/core/factories/bulletogre/btoworldfactory.h
index 96333b7..4a77d46 100644
--- a/src/genecraft/core/factories/bulletogre/btoworldfactory.h
+++ b/src/genecraft/core/factories/bulletogre/btoworldfactory.h
@@ -20,7 +20,7 @@ along with Genecraft-Project. If not, see .
#ifndef BTOWORLDFACTORY_H
#define BTOWORLDFACTORY_H
-#include
+#include
#include "genecraftcoreclasses.h"
namespace GeneCraftCore {
@@ -31,7 +31,7 @@ namespace GeneCraftCore {
static btoWorld* createWorld(btoFactory* factory,
btoShapesFactory* shapesFactory,
- QVariant worldData);
+ QJsonObject worldData);
};
}
diff --git a/src/genecraft/core/factories/ressources/dbrecord.cpp b/src/genecraft/core/factories/ressources/dbrecord.cpp
index 86b9311..ad8a2e8 100644
--- a/src/genecraft/core/factories/ressources/dbrecord.cpp
+++ b/src/genecraft/core/factories/ressources/dbrecord.cpp
@@ -24,30 +24,29 @@ along with Genecraft-Project. If not, see .
#include
#include
-#include "qxtjson.h"
-
#include
-#include
+#include
+#include
namespace GeneCraftCore {
- DbRecord::DbRecord(DataBase db, QString id, QVariant postData, QObject *parent) :
+ DbRecord::DbRecord(DataBase db, QString id, QJsonObject postData, QObject *parent) :
Ressource(parent), db(db), id(id), rev(""), postData(postData)
{
}
- QVariant DbRecord::load() {
+ QJsonObject DbRecord::load() {
error = true;
- if(postData == QVariant()) {
+ if(postData == QJsonObject()) {
QString url = QString("%1:%2/%3/%4").arg(db.url, QString::number(db.port), db.dbName, this->id);
r = NULL;
this->request(url, RGET);
if(!r)
- return QVariant();
+ return QJsonObject();
r->deleteLater();
if(r->error() == 0) {
error = false;
- QVariantMap v = QxtJSON::parse(r->readAll()).toMap();
+ QJsonObject v = QJsonDocument::fromJson(r->readAll()).object();
if(v.contains("_id")) {
this->id = v.find("_id").value().toString();
this->rev = v.find("_rev").value().toString();
@@ -55,25 +54,25 @@ namespace GeneCraftCore {
return v;
} else {
qDebug() << r->readAll();
- QVariantMap v;
+ QJsonObject v;
v.insert("error", r->errorString());
return v;
}
- return QVariant();
+ return QJsonObject();
} else {
QString url = QString("%1:%2/%3/%4").arg(db.url, QString::number(db.port), db.dbName, this->id);
r = NULL;
- this->request(url, RPOST, QxtJSON::stringify(postData));
+ this->request(url, RPOST, QJsonDocument::fromVariant(postData).toJson());
if(!r) {
error = true;
- return QVariant();
+ return QJsonObject();
}
qDebug() << r->error();
r->deleteLater();
if(r->error() == 0) {
error = false;
- QVariantMap v = QxtJSON::parse(r->readAll()).toMap();
+ QJsonObject v = QJsonDocument::fromJson(r->readAll()).object();
if(v.contains("_id")) {
this->id = v.find("_id").value().toString();
this->rev = v.find("_rev").value().toString();
@@ -81,26 +80,25 @@ namespace GeneCraftCore {
return v;
} else {
qDebug() << r->readAll();
- QVariantMap v;
+ QJsonObject v;
v.insert("error", r->errorString());
return v;
}
- return QVariant();
+ return QJsonObject();
}
}
- int DbRecord::save(QVariant data) {
+ int DbRecord::save(QJsonObject data) {
QString url = QString("%1:%2/%3").arg(db.url, QString::number(db.port), db.dbName);
if(this->id != "")
url += "/" + this->id;
- QVariantMap mData = data.toMap();
if(this->id != "")
- mData.insert("_id", this->id);
+ data.insert("_id", this->id);
if(this->rev != "")
- mData.insert("_rev", this->rev);
+ data.insert("_rev", this->rev);
RequestType type = RPUT;
@@ -108,12 +106,12 @@ namespace GeneCraftCore {
type = RPOST;
r = NULL;
- this->request(url, type, QxtJSON::stringify(mData));
+ this->request(url, type, QJsonDocument::fromVariant(data).toJson());
if(!r)
return -1;
if(r->error() == 0) {
- QVariantMap v = QxtJSON::parse(r->readAll()).toMap();
+ QJsonObject v = QJsonDocument::fromJson(r->readAll()).object();
if(v.contains("id")) {
this->id = v.find("id").value().toString();
this->rev = v.find("rev").value().toString();
@@ -148,7 +146,7 @@ namespace GeneCraftCore {
qDebug() << r->error();
if(r->error() == 0) {
- QVariantMap v = QxtJSON::parse(r->readAll()).toMap();
+ QJsonObject v = QJsonDocument::fromJson(r->readAll()).object();
this->error = false;
} else {
diff --git a/src/genecraft/core/factories/ressources/dbrecord.h b/src/genecraft/core/factories/ressources/dbrecord.h
index fa6603b..79fc5b1 100644
--- a/src/genecraft/core/factories/ressources/dbrecord.h
+++ b/src/genecraft/core/factories/ressources/dbrecord.h
@@ -22,6 +22,7 @@ along with Genecraft-Project. If not, see .
#include "ressource.h"
#include
+#include
namespace GeneCraftCore {
@@ -37,10 +38,10 @@ namespace GeneCraftCore {
{
Q_OBJECT
public:
- explicit DbRecord(DataBase db, QString id, QVariant postData = QVariant(), QObject *parent = 0);
+ explicit DbRecord(DataBase db, QString id, QJsonObject postData = QJsonObject(), QObject *parent = 0);
- virtual QVariant load();
- virtual int save(QVariant data);
+ virtual QJsonObject load();
+ virtual int save(QJsonObject data);
virtual int remove();
virtual QString getLocation();
@@ -60,7 +61,7 @@ namespace GeneCraftCore {
DataBase db;
QString id;
QString rev;
- QVariant postData;
+ QJsonObject postData;
protected:
QNetworkReply* r;
diff --git a/src/genecraft/core/factories/ressources/jsonfile.cpp b/src/genecraft/core/factories/ressources/jsonfile.cpp
index db29046..696e90f 100644
--- a/src/genecraft/core/factories/ressources/jsonfile.cpp
+++ b/src/genecraft/core/factories/ressources/jsonfile.cpp
@@ -21,9 +21,9 @@ along with Genecraft-Project. If not, see .
#include
#include
+#include
+#include
-#include "qxtjson.h"
-#include
namespace GeneCraftCore {
JsonFile::JsonFile(QString filename, QObject *parent) :
@@ -33,20 +33,19 @@ namespace GeneCraftCore {
}
- int JsonFile::save(QVariant data) {
+ int JsonFile::save(QJsonObject data) {
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
QTextStream out(&f);
- QString beautifull = Ressource::beautifullJson(data);
- out << beautifull;
+ out << QJsonDocument::fromVariant(data).toJson();
f.close();
return f.error();
}
- QVariant JsonFile::load() {
- QString content;
+ QJsonObject JsonFile::load() {
+ QByteArray content;
if(f.exists()) {
// On ouvre le fichier et on le lit !
if(f.open(QIODevice::ReadOnly | QIODevice::Text))
@@ -56,7 +55,8 @@ namespace GeneCraftCore {
}
f.close();
- return QxtJSON::parse(content);
+ QJsonDocument doc = QJsonDocument::fromJson(content);
+ return doc.object();
}
int JsonFile::remove() {
diff --git a/src/genecraft/core/factories/ressources/jsonfile.h b/src/genecraft/core/factories/ressources/jsonfile.h
index af1d875..ad28988 100644
--- a/src/genecraft/core/factories/ressources/jsonfile.h
+++ b/src/genecraft/core/factories/ressources/jsonfile.h
@@ -21,7 +21,6 @@ along with Genecraft-Project. If not, see .
#define JSONFILE_H
#include "ressource.h"
-#include
#include
namespace GeneCraftCore {
@@ -30,8 +29,8 @@ class JsonFile : public Ressource
public:
explicit JsonFile(QString filename, QObject *parent = 0);
- virtual QVariant load();
- virtual int save(QVariant data);
+ virtual QJsonObject load();
+ virtual int save(QJsonObject data);
virtual int remove();
virtual QString getLocation();
diff --git a/src/genecraft/core/factories/ressources/ressource.cpp b/src/genecraft/core/factories/ressources/ressource.cpp
index a3ff5bf..4969e11 100644
--- a/src/genecraft/core/factories/ressources/ressource.cpp
+++ b/src/genecraft/core/factories/ressources/ressource.cpp
@@ -20,10 +20,12 @@ along with Genecraft-Project. If not, see .
#include "ressource.h"
#include "dbrecord.h"
#include "jsonfile.h"
-#include
#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
namespace GeneCraftCore {
int cptRessource = 0;
@@ -38,11 +40,10 @@ namespace GeneCraftCore {
}
- Ressource* Ressource::unserialize(QVariant v) {
- QVariantMap map = v.toMap();
+ Ressource* Ressource::unserialize(QJsonObject map) {
if(map["type"].toString() == "include") {
- map = map["data"].toMap();
+ map = map["data"].toObject();
} else {
return NULL;
}
@@ -68,11 +69,11 @@ namespace GeneCraftCore {
}
- QVariant Ressource::load(QVariant data) {
+ QJsonObject Ressource::load(QJsonObject data) {
Ressource* r = unserialize(data);
// Include of another data ?
if(r) {
- QVariant includedData = r->load();
+ QJsonObject includedData = r->load();
delete r;
return load(includedData); // Nested inclusion ?
} else // Already loaded, not included
@@ -80,9 +81,9 @@ namespace GeneCraftCore {
}
- QVariant Ressource::serialize(JsonFile *r) {
- QVariantMap ressourceMap;
- QVariantMap data;
+ QJsonObject Ressource::serialize(JsonFile *r) {
+ QJsonObject ressourceMap;
+ QJsonObject data;
data.insert("type", "file");
@@ -95,9 +96,9 @@ namespace GeneCraftCore {
}
- QVariant Ressource::serialize(DbRecord *r) {
- QVariantMap ressourceMap;
- QVariantMap data;
+ QJsonObject Ressource::serialize(DbRecord *r) {
+ QJsonObject ressourceMap;
+ QJsonObject data;
data.insert("type", "db");
@@ -114,43 +115,10 @@ namespace GeneCraftCore {
}
QString Ressource::beautifullJson(QString data) {
-
- static QScriptEngine* e = NULL;
-
- if(!e) {
- e = new QScriptEngine();
- QFile fjs(":/js/js-beautifull");
- fjs.open(QIODevice::ReadOnly |QIODevice::Text);
- QString js = fjs.readAll();
- e->evaluate(js);
- }
-
- QScriptValue beautifullJson = e->evaluate("js_beautify");
- QScriptValue bb = beautifullJson.call(QScriptValue(),
- QScriptValueList()
- << data
- << e->evaluate("({'indent_size': 1,'indent_char': ' '})"));
- //out << beautifullJson.toString();
- return bb.toString();
+ return QJsonDocument::fromJson(data.toUtf8()).toJson(QJsonDocument::Indented);
}
- QString Ressource::beautifullJson(QVariant data) {
- static QScriptEngine* e = NULL;
-
- if(!e) {
- e = new QScriptEngine();
- QFile fjs(":/js/js-beautifull");
- fjs.open(QIODevice::ReadOnly |QIODevice::Text);
- QString js = fjs.readAll();
- e->evaluate(js);
- }
-
- QScriptValue beautifullJson = e->evaluate("js_beautify");
- QScriptValue bb = beautifullJson.call(QScriptValue(),
- QScriptValueList()
- << QxtJSON::stringify(data)
- << e->evaluate("({'indent_size': 1,'indent_char': ' '})"));
- //out << beautifullJson.toString();
- return bb.toString();
+ QString Ressource::beautifullJson(QJsonObject data) {
+ return QJsonDocument::fromVariant(data).toJson(QJsonDocument::Indented);
}
}
diff --git a/src/genecraft/core/factories/ressources/ressource.h b/src/genecraft/core/factories/ressources/ressource.h
index 7f52a43..2dd0a6b 100644
--- a/src/genecraft/core/factories/ressources/ressource.h
+++ b/src/genecraft/core/factories/ressources/ressource.h
@@ -21,7 +21,6 @@ along with Genecraft-Project. If not, see .
#define RESSOURCE_H
#include
-#include
namespace GeneCraftCore {
@@ -39,14 +38,14 @@ namespace GeneCraftCore {
/**
* Load data from ressource
*/
- virtual QVariant load() = 0;
+ virtual QJsonObject load() = 0;
/**
* Save data to ressource
*
* @return 0 if ok, else error code.
*/
- virtual int save(QVariant data) = 0;
+ virtual int save(QJsonObject data) = 0;
/**
* Remove ressource
@@ -61,22 +60,24 @@ namespace GeneCraftCore {
/**
* Create a ressource from a ressource metadata
*/
- static Ressource* unserialize(QVariant v);
+ static Ressource* unserialize(QJsonObject v);
/**
- * Create an include QVariant bloc,
+ * Create an include QJsonObject bloc,
* which can be loaded by the static Ressource::load function
*/
- static QVariant serialize(JsonFile *r);
- static QVariant serialize(DbRecord *r);
+ static QJsonObject serialize(JsonFile *r);
+ static QJsonObject serialize(DbRecord *r);
/**
* Load data from either a ressource data, or the real data
*/
- static QVariant load(QVariant data);
+ static QJsonObject load(QJsonObject data);
+
+ static QString beautifullJson(QString);
+ static QString beautifullJson(QJsonObject);
+
- static QString beautifullJson(QVariant data);
- static QString beautifullJson(QString data);
};
diff --git a/src/genecraft/core/factories/ressources/ressourcesmanager.cpp b/src/genecraft/core/factories/ressources/ressourcesmanager.cpp
index 0ec9a79..627adcb 100644
--- a/src/genecraft/core/factories/ressources/ressourcesmanager.cpp
+++ b/src/genecraft/core/factories/ressources/ressourcesmanager.cpp
@@ -21,6 +21,8 @@ along with Genecraft-Project. If not, see .
#include "jsonfile.h"
#include "dbrecord.h"
#include
+#include
+#include
namespace GeneCraftCore {
@@ -45,13 +47,12 @@ namespace GeneCraftCore {
void RessourcesManager::getAllWorld() {
DbRecord * listDb = new DbRecord(db, "_design/worlds/_view/all");
- QVariant worlds = listDb->load();
+ QJsonObject worlds = listDb->load();
delete listDb;
- QVariantMap worldsMap = worlds.toMap();
- QVariantList worldsList = worldsMap["rows"].toList();
- foreach(QVariant world, worldsList) {
- DataWrapper dataw = {world.toMap()["value"].toMap(), NULL};
+ QJsonArray worldsList = worlds["rows"].toArray();
+ foreach(QJsonValue world, worldsList) {
+ DataWrapper dataw = {world.toObject()["value"].toObject(), NULL};
this->examine(dataw);
}
}
@@ -59,26 +60,24 @@ namespace GeneCraftCore {
void RessourcesManager::getAllCreatures() {
//http://www.genecraft-project.com/db/genecraft/_design/creature/_view/all?include_docs=true
DbRecord * listDb = new DbRecord(db, "_design/creature/_view/all?include_docs=true");
- QVariant creatures = listDb->load();
+ QJsonObject creatures = listDb->load();
delete listDb;
- QVariantMap creaturesMap = creatures.toMap();
- QVariantList creaturesList = creaturesMap["rows"].toList();
- foreach(QVariant creature, creaturesList) {
- DataWrapper dataw = {creature.toMap()["doc"].toMap(), NULL};
+ QJsonArray creaturesList = creatures["rows"].toArray();
+ foreach(QJsonValue creature, creaturesList) {
+ DataWrapper dataw = {creature.toObject()["doc"].toObject(), NULL};
this->examine(dataw);
}
}
void RessourcesManager::getAllExperiments() {
DbRecord * listDb = new DbRecord(db, "_design/experiments/_view/all");
- QVariant experiments = listDb->load();
+ QJsonObject experiments = listDb->load();
delete listDb;
- QVariantMap experimentsMap = experiments.toMap();
- QVariantList experimentsList = experimentsMap["rows"].toList();
- foreach(QVariant experiment, experimentsList) {
- DataWrapper dataw = {experiment.toMap()["value"].toMap(), NULL};
+ QJsonArray experimentsList = experiments["rows"].toArray();
+ foreach(QJsonValue experiment, experimentsList) {
+ DataWrapper dataw = {experiment.toObject()["value"].toObject(), NULL};
this->examine(dataw);
}
}
@@ -98,7 +97,7 @@ namespace GeneCraftCore {
| QDir::Reversed)) {
JsonFile* f = new JsonFile(directory.absoluteFilePath(filename));
- DataWrapper dataw = {f->load().toMap(), f};
+ DataWrapper dataw = {f->load(), f};
this->examine(dataw);
}
}
@@ -116,7 +115,7 @@ namespace GeneCraftCore {
}
void RessourcesManager::examine(DataWrapper dataw) {
- QVariantMap dataMap = dataw.data;
+ QJsonObject dataMap = dataw.data;
// Experience ?
if(dataMap.contains("author") && dataMap.contains("duration")) {
@@ -124,7 +123,7 @@ namespace GeneCraftCore {
// Take the inside world
// if(dataMap.contains("world")) {
-// QVariantMap worldMap = dataMap["world"].toMap();
+// QJsonObject worldMap = dataMap["world"].toObject();
// DataWrapper dataWorld = {worldMap, NULL};
// // no add two times the same world
@@ -152,7 +151,7 @@ namespace GeneCraftCore {
// if it's a result, convert to genome...
if(dataMap.contains("type") && dataMap["type"].toString() == "result") {
- dataMap = dataMap["genome"].toMap();
+ dataMap = dataMap["genome"].toObject();
}
// Creature ?
diff --git a/src/genecraft/core/factories/ressources/ressourcesmanager.h b/src/genecraft/core/factories/ressources/ressourcesmanager.h
index b95006a..0a35b49 100644
--- a/src/genecraft/core/factories/ressources/ressourcesmanager.h
+++ b/src/genecraft/core/factories/ressources/ressourcesmanager.h
@@ -28,7 +28,7 @@ namespace GeneCraftCore {
struct DataWrapper {
- QVariantMap data;
+ QJsonObject data;
Ressource *r;
};
diff --git a/src/genecraft/core/ui/widgets/entities/bonepropertiescontroller.cpp b/src/genecraft/core/ui/widgets/entities/bonepropertiescontroller.cpp
index 299e5fb..4d46398 100644
--- a/src/genecraft/core/ui/widgets/entities/bonepropertiescontroller.cpp
+++ b/src/genecraft/core/ui/widgets/entities/bonepropertiescontroller.cpp
@@ -274,8 +274,8 @@ void BonePropertiesController::saveChanges()
{
case 0 :
motor->m_enableMotor = this->ui->cbEnable_m1->isChecked();
- motor->m_targetVelocity = this->ui->leTargetVelocity_m1->text().toFloat();
- motor->m_maxMotorForce = this->ui->leMaxMotorForce_m1->text().toFloat();
+ motor->m_targetVelocity = this->ui->leTargetVelocity_m1->text().toDouble();
+ motor->m_maxMotorForce = this->ui->leMaxMotorForce_m1->text().toDouble();
motor->m_loLimit = this->ui->dAngularLowerLimitX->value() / 100.0;
motor->m_hiLimit = this->ui->dAngularUpperLimitX->value() / 100.0;
this->ui->lAngularLowerLimitX->setText(QString::number(motor->m_loLimit));
@@ -284,8 +284,8 @@ void BonePropertiesController::saveChanges()
case 1 :
motor->m_enableMotor = this->ui->cbEnable_m2->isChecked();
- motor->m_targetVelocity = this->ui->leTargetVelocity_m2->text().toFloat();
- motor->m_maxMotorForce = this->ui->leMaxMotorForce_m2->text().toFloat();
+ motor->m_targetVelocity = this->ui->leTargetVelocity_m2->text().toDouble();
+ motor->m_maxMotorForce = this->ui->leMaxMotorForce_m2->text().toDouble();
motor->m_loLimit = this->ui->dAngularLowerLimitY->value() / 100.0;
motor->m_hiLimit = this->ui->dAngularUpperLimitY->value() / 100.0;
this->ui->lAngularLowerLimitY->setText(QString::number(motor->m_loLimit));
@@ -295,8 +295,8 @@ void BonePropertiesController::saveChanges()
case 2 :
motor->m_enableMotor = this->ui->cbEnable_m3->isChecked();
- motor->m_targetVelocity = this->ui->leTargetVelocity_m3->text().toFloat();
- motor->m_maxMotorForce = this->ui->leMaxMotorForce_m3->text().toFloat();
+ motor->m_targetVelocity = this->ui->leTargetVelocity_m3->text().toDouble();
+ motor->m_maxMotorForce = this->ui->leMaxMotorForce_m3->text().toDouble();
motor->m_loLimit = this->ui->dAngularLowerLimitZ->value() / 100.0;
motor->m_hiLimit = this->ui->dAngularUpperLimitZ->value() / 100.0;
this->ui->lAngularLowerLimitZ->setText(QString::number(motor->m_loLimit));
diff --git a/src/genecraft/core/ui/widgets/entities/entitypropertiescontroller.cpp b/src/genecraft/core/ui/widgets/entities/entitypropertiescontroller.cpp
index eb25d4d..f3c9b2a 100644
--- a/src/genecraft/core/ui/widgets/entities/entitypropertiescontroller.cpp
+++ b/src/genecraft/core/ui/widgets/entities/entitypropertiescontroller.cpp
@@ -20,7 +20,6 @@ along with Genecraft-Project. If not, see .
#include "entitypropertiescontroller.h"
#include "ui_entitypropertiescontroller.h"
-#include
#include
#include
diff --git a/src/genecraft/core/ui/widgets/entities/fixationpropertiescontroller.cpp b/src/genecraft/core/ui/widgets/entities/fixationpropertiescontroller.cpp
index 3b9d8e4..3d3e644 100644
--- a/src/genecraft/core/ui/widgets/entities/fixationpropertiescontroller.cpp
+++ b/src/genecraft/core/ui/widgets/entities/fixationpropertiescontroller.cpp
@@ -168,9 +168,9 @@ void FixationPropertiesController::fixInTheAir()
if(fixation->isFixedInTheAir())
fixation->unfixInTheAir();
else
- fixation->fixeInTheAir(/*btVector3(ui->leX->text().toFloat(),
- ui->leY->text().toFloat(),
- ui->leZ->text().toFloat())*/);
+ fixation->fixeInTheAir(/*btVector3(ui->leX->text().toDouble(),
+ ui->leY->text().toDouble(),
+ ui->leZ->text().toDouble())*/);
}
}
diff --git a/src/genecraft/core/ui/widgets/entities/generic6dofconstraintcontroller.cpp b/src/genecraft/core/ui/widgets/entities/generic6dofconstraintcontroller.cpp
index fcd2150..829ceb3 100644
--- a/src/genecraft/core/ui/widgets/entities/generic6dofconstraintcontroller.cpp
+++ b/src/genecraft/core/ui/widgets/entities/generic6dofconstraintcontroller.cpp
@@ -36,9 +36,9 @@ Generic6DofConstraintController::~Generic6DofConstraintController()
void Generic6DofConstraintController::saveChanges()
{
- this->constraint->getFrameOffsetA().getBasis().setEulerZYX(this->ui->leEulerRotX->text().toFloat(),
- this->ui->leEulerRotY->text().toFloat(),
- this->ui->leEulerRotZ->text().toFloat());
+ this->constraint->getFrameOffsetA().getBasis().setEulerZYX(this->ui->leEulerRotX->text().toDouble(),
+ this->ui->leEulerRotY->text().toDouble(),
+ this->ui->leEulerRotZ->text().toDouble());
btRotationalLimitMotor *motor;
for(int i=0;i<3;i++)
@@ -50,38 +50,38 @@ void Generic6DofConstraintController::saveChanges()
case 0 :
motor->m_enableMotor = this->ui->cbEnable_m1->isChecked();
- motor->m_targetVelocity = this->ui->leTargetVelocity_m1->text().toFloat();
- motor->m_maxMotorForce = this->ui->leMaxMotorForce_m1->text().toFloat();
- motor->m_maxLimitForce = this->ui->leMaxLimitForce_m1->text().toFloat();
- motor->m_bounce = this->ui->leBounce_m1->text().toFloat();
- motor->m_damping = this->ui->leDamping_m1->text().toFloat();
-
- motor->m_loLimit = this->ui->leAngularLowerLimit_x->text().toFloat();
- motor->m_hiLimit = this->ui->leAngularUpperLimit_x->text().toFloat();
+ motor->m_targetVelocity = this->ui->leTargetVelocity_m1->text().toDouble();
+ motor->m_maxMotorForce = this->ui->leMaxMotorForce_m1->text().toDouble();
+ motor->m_maxLimitForce = this->ui->leMaxLimitForce_m1->text().toDouble();
+ motor->m_bounce = this->ui->leBounce_m1->text().toDouble();
+ motor->m_damping = this->ui->leDamping_m1->text().toDouble();
+
+ motor->m_loLimit = this->ui->leAngularLowerLimit_x->text().toDouble();
+ motor->m_hiLimit = this->ui->leAngularUpperLimit_x->text().toDouble();
break;
case 1 :
motor->m_enableMotor = this->ui->cbEnable_m2->isChecked();
- motor->m_targetVelocity = this->ui->leTargetVelocity_m2->text().toFloat();
- motor->m_maxMotorForce = this->ui->leMaxMotorForce_m2->text().toFloat();
- motor->m_maxLimitForce = this->ui->leMaxLimitForce_m2->text().toFloat();
- motor->m_bounce = this->ui->leBounce_m2->text().toFloat();
- motor->m_damping = this->ui->leDamping_m2->text().toFloat();
-
- motor->m_loLimit = this->ui->leAngularLowerLimit_y->text().toFloat();
- motor->m_hiLimit = this->ui->leAngularUpperLimit_y->text().toFloat();
+ motor->m_targetVelocity = this->ui->leTargetVelocity_m2->text().toDouble();
+ motor->m_maxMotorForce = this->ui->leMaxMotorForce_m2->text().toDouble();
+ motor->m_maxLimitForce = this->ui->leMaxLimitForce_m2->text().toDouble();
+ motor->m_bounce = this->ui->leBounce_m2->text().toDouble();
+ motor->m_damping = this->ui->leDamping_m2->text().toDouble();
+
+ motor->m_loLimit = this->ui->leAngularLowerLimit_y->text().toDouble();
+ motor->m_hiLimit = this->ui->leAngularUpperLimit_y->text().toDouble();
break;
case 2 :
motor->m_enableMotor = this->ui->cbEnable_m3->isChecked();
- motor->m_targetVelocity = this->ui->leTargetVelocity_m3->text().toFloat();
- motor->m_maxMotorForce = this->ui->leMaxMotorForce_m3->text().toFloat();
- motor->m_maxLimitForce = this->ui->leMaxLimitForce_m3->text().toFloat();
- motor->m_bounce = this->ui->leBounce_m3->text().toFloat();
- motor->m_damping = this->ui->leDamping_m3->text().toFloat();
-
- motor->m_loLimit = this->ui->leAngularLowerLimit_z->text().toFloat();
- motor->m_hiLimit = this->ui->leAngularUpperLimit_z->text().toFloat();
+ motor->m_targetVelocity = this->ui->leTargetVelocity_m3->text().toDouble();
+ motor->m_maxMotorForce = this->ui->leMaxMotorForce_m3->text().toDouble();
+ motor->m_maxLimitForce = this->ui->leMaxLimitForce_m3->text().toDouble();
+ motor->m_bounce = this->ui->leBounce_m3->text().toDouble();
+ motor->m_damping = this->ui->leDamping_m3->text().toDouble();
+
+ motor->m_loLimit = this->ui->leAngularLowerLimit_z->text().toDouble();
+ motor->m_hiLimit = this->ui->leAngularUpperLimit_z->text().toDouble();
break;
}
}
diff --git a/src/genecraft/core/ui/widgets/experiments/experimentctrl.cpp b/src/genecraft/core/ui/widgets/experiments/experimentctrl.cpp
index 91a6df5..8b382ae 100644
--- a/src/genecraft/core/ui/widgets/experiments/experimentctrl.cpp
+++ b/src/genecraft/core/ui/widgets/experiments/experimentctrl.cpp
@@ -71,7 +71,7 @@ namespace GeneCraftCore {
connect(iim, SIGNAL(sLoadExperiment(Experiment*)),this,SLOT(loadExperiment(Experiment*)));
connect(this, SIGNAL(sLoadResult(Result*)),iim,SLOT(loadResult(Result*)));
- connect(this, SIGNAL(sAddEntity(QVariantMap,Ressource*)), iim, SLOT(loadEntity(QVariantMap, Ressource*)));
+ connect(this, SIGNAL(sAddEntity(QJsonObject,Ressource*)), iim, SLOT(loadEntity(QJsonObject, Ressource*)));
}
void ExperimentCtrl::refresh() {
@@ -188,7 +188,7 @@ namespace GeneCraftCore {
{
if(this->ui->twResults->currentItem()) {
Result* r = this->results[this->ui->twResults->currentIndex().row()];
- emit sAddEntity(r->serialize().toMap(), NULL);
+ emit sAddEntity(r->serialize(), NULL);
}
}
diff --git a/src/genecraft/core/ui/widgets/experiments/experimentctrl.h b/src/genecraft/core/ui/widgets/experiments/experimentctrl.h
index 64c28f8..739f75b 100644
--- a/src/genecraft/core/ui/widgets/experiments/experimentctrl.h
+++ b/src/genecraft/core/ui/widgets/experiments/experimentctrl.h
@@ -46,7 +46,7 @@ namespace GeneCraftCore {
void connectToInspectorInputManager(GeneCraftCore::InspectorsInputManager * iim);
signals:
- void sAddEntity(QVariantMap genome, Ressource* r);
+ void sAddEntity(QJsonObject genome, Ressource* r);
void sLoadResult(Result*);
void newDataAvailable();
diff --git a/src/genecraft/core/ui/widgets/experiments/experimentspropertiescontroller.cpp b/src/genecraft/core/ui/widgets/experiments/experimentspropertiescontroller.cpp
index 7d44444..e092bb3 100644
--- a/src/genecraft/core/ui/widgets/experiments/experimentspropertiescontroller.cpp
+++ b/src/genecraft/core/ui/widgets/experiments/experimentspropertiescontroller.cpp
@@ -24,6 +24,8 @@ along with Genecraft-Project. If not, see .
#include
#include
#include
+#include
+#include
#include "experiment/experiment.h"
@@ -39,7 +41,6 @@ along with Genecraft-Project. If not, see .
// ressources
#include "ressources/jsonfile.h"
-#include "qxtjson.h"
#include "ressourcesItems.h"
#include "ressources/ressourcesmanager.h"
@@ -50,6 +51,7 @@ along with Genecraft-Project. If not, see .
// floor dialog
#include "floordialog.h"
+
namespace GeneCraftCore {
QList gravitiesName;
@@ -210,7 +212,7 @@ void ExperimentsPropertiesController::addFromGenome() {
QString text = ui->teGenome->toPlainText().trimmed();
if(!text.isEmpty())
- ui->twEntitiesSelected->insertTopLevelItem(0,new EntityTreeWidgetItem(QxtJSON::parse(text).toMap()));
+ ui->twEntitiesSelected->insertTopLevelItem(0,new EntityTreeWidgetItem(QJsonDocument::fromJson(text.toUtf8()).object()));
else
qDebug() << "genome empty";
}
@@ -349,7 +351,7 @@ void ExperimentsPropertiesController::setExperiment(Experiment *experiment){
// default check in QtCreator, check false to emit toggle and disable others...
ui->gbFixedGenomes->setChecked(false);
- QVariantMap seedsMap = experiment->getSeedInfo();
+ QJsonObject seedsMap = experiment->getSeedInfo();
QString seedType = seedsMap["type"].toString();
if(seedType == "family") {
@@ -365,22 +367,22 @@ void ExperimentsPropertiesController::setExperiment(Experiment *experiment){
ui->gbFixedGenomes->setChecked(true);
if(seedsMap.contains("genomes"))
{
- QVariantList genomesList = seedsMap["genomes"].toList();
+ QJsonArray genomesList = seedsMap["genomes"].toArray();
- foreach(QVariant genome, genomesList)
- ui->twEntitiesSelected->insertTopLevelItem(0,new EntityTreeWidgetItem(genome.toMap()));
+ foreach(QJsonValue genome, genomesList)
+ ui->twEntitiesSelected->insertTopLevelItem(0,new EntityTreeWidgetItem(genome.toObject()));
}
}
}
}
-void ExperimentsPropertiesController::setWorld(QVariantMap worldData){
+void ExperimentsPropertiesController::setWorld(QJsonObject worldData){
// -- world --
ui->leWorldName->setText(worldData["name"].toString());
// -- Biome --
- QVariantMap biomeMap = worldData["biome"].toMap();
+ QJsonObject biomeMap = worldData["biome"].toObject();
double gravity = biomeMap["gravity"].toDouble();
for(int i=0; icbSkyMaterial->setCurrentIndex(i);
// lights
- ui->teLights->setText(Ressource::beautifullJson(biomeMap["lights"]));
+ ui->teLights->setText(Ressource::beautifullJson(biomeMap["lights"].toObject()));
// -- Scene --
- QVariantMap sceneMap = worldData["scene"].toMap();
+ QJsonObject sceneMap = worldData["scene"].toObject();
// floor
- QVariantMap floorMap = sceneMap["floor"].toMap();
+ QJsonObject floorMap = sceneMap["floor"].toObject();
QString type = floorMap["type"].toString();
this->ui->lblFloorType->setText(type);
@@ -426,7 +428,7 @@ void ExperimentsPropertiesController::setWorld(QVariantMap worldData){
ui->cbFloor->setCurrentIndex(0);*/
// camera
- QVariantMap camMap = sceneMap["camera"].toMap();
+ QJsonObject camMap = sceneMap["camera"].toObject();
ui->leCamPosX->setText(camMap["posX"].toString());
ui->leCamPosY->setText(camMap["posY"].toString());
ui->leCamPosZ->setText(camMap["posZ"].toString());
@@ -435,10 +437,10 @@ void ExperimentsPropertiesController::setWorld(QVariantMap worldData){
ui->leCamTargetZ->setText(camMap["targetZ"].toString());
// shapes
- ui->teStaticShapes->setText(Ressource::beautifullJson(sceneMap["shapes"]));
+ ui->teStaticShapes->setText(Ressource::beautifullJson(sceneMap["shapes"].toObject()));
// spawns
- ui->teSpawns->setText(Ressource::beautifullJson(sceneMap["spawns"]));
+ ui->teSpawns->setText(Ressource::beautifullJson(sceneMap["spawns"].toObject()));
}
ExperimentsPropertiesController::~ExperimentsPropertiesController() {
@@ -551,9 +553,9 @@ void ExperimentsPropertiesController::updateStructures() {
// Seed
experiment->setSeedInfo(getSeedMap());
}
-QVariantMap ExperimentsPropertiesController::getSeedMap() {
+QJsonObject ExperimentsPropertiesController::getSeedMap() {
- QVariantMap seedMap;
+ QJsonObject seedMap;
if(ui->gbFamily->isChecked()) {
seedMap.insert("type","family");
@@ -563,7 +565,7 @@ QVariantMap ExperimentsPropertiesController::getSeedMap() {
seedMap.insert("type","fixedGenomes");
- QVariantList genomes;
+ QJsonArray genomes;
for(int i=0; i < ui->twEntitiesSelected->topLevelItemCount(); ++i) {
EntityTreeWidgetItem *entityItem = (EntityTreeWidgetItem *) ui->twEntitiesSelected->topLevelItem(i);
@@ -576,22 +578,22 @@ QVariantMap ExperimentsPropertiesController::getSeedMap() {
}
-QVariantMap ExperimentsPropertiesController::getWorldMap() {
+QJsonObject ExperimentsPropertiesController::getWorldMap() {
// World
- QVariantMap worldMap = experiment->getWorldDataMap();
+ QJsonObject worldMap = experiment->getWorldDataMap();
worldMap.insert("name",ui->leWorldName->text());
// -- Biome --
- QVariantMap biomeMap;
+ QJsonObject biomeMap;
biomeMap.insert("gravity",gravities[ui->cbGravity->currentIndex()]);
- biomeMap.insert("lights",QxtJSON::parse(ui->teLights->toPlainText()));
+ biomeMap.insert("lights",QJsonDocument::fromJson(ui->teLights->toPlainText().toUtf8()).object());
biomeMap.insert("skyMaterial",skyMaterials[ui->cbSkyMaterial->currentIndex()]);
worldMap.insert("biome",biomeMap);
// -- Scene --
- QVariantMap sceneMap = experiment->getWorldDataMap()["scene"].toMap();
- QVariantMap camMap;
+ QJsonObject sceneMap = experiment->getWorldDataMap()["scene"].toObject();
+ QJsonObject camMap;
camMap.insert("posX",ui->leCamPosX->text().toDouble());
camMap.insert("posY",ui->leCamPosY->text().toDouble());
camMap.insert("posZ",ui->leCamPosZ->text().toDouble());
@@ -600,7 +602,7 @@ QVariantMap ExperimentsPropertiesController::getWorldMap() {
camMap.insert("targetZ",ui->leCamTargetZ->text().toDouble());
sceneMap.insert("camera",camMap);
- //QVariantMap floorMap;
+ //QJsonObject floorMap;
//floorMap.insert("type",ui->cbFloor->currentText());
/*if(ui->cbFloor->currentText() == "flatland")
@@ -610,8 +612,8 @@ QVariantMap ExperimentsPropertiesController::getWorldMap() {
*/
//sceneMap.insert("floor",floorMap);
- sceneMap.insert("shapes",QxtJSON::parse(ui->teStaticShapes->toPlainText()));
- sceneMap.insert("spawns",QxtJSON::parse(ui->teSpawns->toPlainText()));
+ sceneMap.insert("shapes",QJsonDocument::fromJson(ui->teStaticShapes->toPlainText().toUtf8()).object());
+ sceneMap.insert("spawns",QJsonDocument::fromJson(ui->teSpawns->toPlainText().toUtf8()).object());
worldMap.insert("scene",sceneMap);
return worldMap;
@@ -629,7 +631,7 @@ void ExperimentsPropertiesController::loadExpFromFile() {
// Load Generic Entity
Ressource* from = new JsonFile(selectedFile);
- QVariant expData = from->load();
+ QJsonObject expData = from->load();
Experiment *experiment = new Experiment(expData);
experiment->setRessource(from);
setExperiment(experiment);
@@ -649,14 +651,14 @@ void ExperimentsPropertiesController::loadWorldFromFile() {
// Load Generic Entity
Ressource* from = new JsonFile(selectedFile);
- QVariant data = from->load();
- setWorld(data.toMap());
+ QJsonObject data = from->load();
+ setWorld(data);
}
}
void ExperimentsPropertiesController::saveWorldToFile() {
- QVariantMap worldMap = getWorldMap();
+ QJsonObject worldMap = getWorldMap();
// To new file
QString selectedFile = QFileDialog::getSaveFileName(this, "Save your world", "./ressources/" + worldMap["name"].toString() + ".world", "World (*.world)");
@@ -705,8 +707,8 @@ void ExperimentsPropertiesController::takeFromCamera() {
void GeneCraftCore::ExperimentsPropertiesController::on_btnFloor_clicked()
{
- QVariantMap map = experiment->getWorldDataMap();
- QVariant floorMap = map["floor"];
+ QJsonObject map = experiment->getWorldDataMap();
+ QJsonObject floorMap = map["floor"].toObject();
FloorDialog fd(floorMap);
fd.exec();
floorMap = fd.serialize();
@@ -715,7 +717,7 @@ void GeneCraftCore::ExperimentsPropertiesController::on_btnFloor_clicked()
map.insert("floor", floorMap);
experiment->setWorldData(map);
- this->ui->lblFloorType->setText(floorMap.toMap()["type"].toString());
+ this->ui->lblFloorType->setText(floorMap["type"].toString());
}
}
diff --git a/src/genecraft/core/ui/widgets/experiments/experimentspropertiescontroller.h b/src/genecraft/core/ui/widgets/experiments/experimentspropertiescontroller.h
index 5b06c29..bbbafe3 100644
--- a/src/genecraft/core/ui/widgets/experiments/experimentspropertiescontroller.h
+++ b/src/genecraft/core/ui/widgets/experiments/experimentspropertiescontroller.h
@@ -21,7 +21,7 @@ along with Genecraft-Project. If not, see .
#define EXPERIMENTSPROPERTIESCONTROLLER_H
#include
-#include
+#include
#include "genecraftcoreclasses.h"
namespace Ui {
@@ -42,8 +42,8 @@ class ExperimentsPropertiesController : public QWidget
void connectToInspectorInputManager(GeneCraftCore::InspectorsInputManager * iim);
- QVariantMap getWorldMap();
- QVariantMap getSeedMap();
+ QJsonObject getWorldMap();
+ QJsonObject getSeedMap();
signals:
void sLoadExperiment(Experiment *experiment);
@@ -64,7 +64,7 @@ public slots:
void loadWorldFromFile();
void saveWorldToFile();
- void setWorld(QVariantMap worldData);
+ void setWorld(QJsonObject worldData);
void setExperiment(GeneCraftCore::Experiment *exp);
void removeEntityFromSeed();
diff --git a/src/genecraft/core/ui/widgets/experiments/floordialog.cpp b/src/genecraft/core/ui/widgets/experiments/floordialog.cpp
index db2826b..5663ea3 100644
--- a/src/genecraft/core/ui/widgets/experiments/floordialog.cpp
+++ b/src/genecraft/core/ui/widgets/experiments/floordialog.cpp
@@ -19,15 +19,16 @@ along with Genecraft-Project. If not, see .
#include "floordialog.h"
#include "ui_floordialog.h"
+#include
namespace GeneCraftCore {
- FloorDialog::FloorDialog(QVariant floorData, QWidget *parent) :
+ FloorDialog::FloorDialog(QJsonObject floorData, QWidget *parent) :
QDialog(parent),
ui(new Ui::FloorDialog)
{
ui->setupUi(this);
- QString type = floorData.toMap()["type"].toString();
+ QString type = floorData["type"].toString();
if(type == "nofloor") {
this->ui->cmbType->setCurrentIndex(0);
} else if (type == "flatland") {
@@ -46,23 +47,22 @@ namespace GeneCraftCore {
loadBoxes(floorData);
} else if (type == "slope") {
this->ui->cmbType->setCurrentIndex(3);
- this->ui->spbSIncl->setValue(floorData.toMap()["inclinaison"].toFloat());
+ this->ui->spbSIncl->setValue(floorData["inclinaison"].toDouble());
}
}
- void FloorDialog::loadBoxes(QVariant data) {
- QVariantMap map = data.toMap();
- float width = map["width"].toFloat();
- float minHeight = map["minHeight"].toFloat();
- float maxHeight = map["maxHeight"].toFloat();
+ void FloorDialog::loadBoxes(QJsonObject map) {
+ float width = map["width"].toDouble();
+ float minHeight = map["minHeight"].toDouble();
+ float maxHeight = map["maxHeight"].toDouble();
this->ui->spbBWidth->setValue(width);
this->ui->spbBMinHeight->setValue(minHeight);
this->ui->spbBMaxHeight->setValue(maxHeight);
}
- QVariant FloorDialog::serialize() {
- QVariantMap data;
+ QJsonObject FloorDialog::serialize() {
+ QJsonObject data;
QString type = this->ui->cmbType->currentText();
diff --git a/src/genecraft/core/ui/widgets/experiments/floordialog.h b/src/genecraft/core/ui/widgets/experiments/floordialog.h
index 2e05a71..c1fcfd3 100644
--- a/src/genecraft/core/ui/widgets/experiments/floordialog.h
+++ b/src/genecraft/core/ui/widgets/experiments/floordialog.h
@@ -21,7 +21,6 @@ along with Genecraft-Project. If not, see .
#define FLOORDIALOG_H
#include
-#include
namespace Ui {
class FloorDialog;
@@ -34,14 +33,14 @@ namespace GeneCraftCore {
Q_OBJECT
public:
- explicit FloorDialog(QVariant floorData, QWidget *parent = 0);
- QVariant serialize();
+ explicit FloorDialog(QJsonObject floorData, QWidget *parent = 0);
+ QJsonObject serialize();
~FloorDialog();
private:
Ui::FloorDialog *ui;
- void loadBoxes(QVariant data);
+ void loadBoxes(QJsonObject data);
private slots:
void on_cmbBoxType_currentIndexChanged(QString );
diff --git a/src/genecraft/core/ui/widgets/experiments/ressourcesItems.h b/src/genecraft/core/ui/widgets/experiments/ressourcesItems.h
index 069c062..33be324 100644
--- a/src/genecraft/core/ui/widgets/experiments/ressourcesItems.h
+++ b/src/genecraft/core/ui/widgets/experiments/ressourcesItems.h
@@ -23,7 +23,6 @@ along with Genecraft-Project. If not, see .
#include
#include
#include
-#include
#include
#include "result.h"
#include
@@ -90,8 +89,8 @@ class WorldTreeWidgetItem : public QTreeWidgetItem
{
this->dataw = dataw;
- QVariantMap biome = dataw.data["biome"].toMap();
- QVariantMap scene = dataw.data["scene"].toMap();
+ QJsonObject biome = dataw.data["biome"].toObject();
+ QJsonObject scene = dataw.data["scene"].toObject();
setText(0,dataw.data["name"].toString());
setText(1,QString::number(biome["gravity"].toDouble()));
@@ -112,14 +111,14 @@ class ResultTreeWidgetItem : public QTreeWidgetItem
setText(0, QString::number(r->getFitness(), 10, 4));
setText(1, r->getWorker());
- setText(2, QString::number(r->getGenome().toMap()["origins"].toMap()["generation"].toInt()));
+ setText(2, QString::number(r->getGenome()["origins"].toObject()["generation"].toInt()));
}
bool operator<(const QTreeWidgetItem &other)const {
int column = treeWidget()->sortColumn();
if(column == 0) {
// sorting by fitness
- return text(0).toFloat() < other.text(0).toFloat();
+ return text(0).toDouble() < other.text(0).toDouble();
}
else if(column == 2) {
return text(2).toInt() < other.text(2).toInt();
@@ -139,7 +138,7 @@ class EntityTreeWidgetItem : public QTreeWidgetItem
{
this->dataw = dataw;
- QVariantMap origins = dataw.data["origins"].toMap();
+ QJsonObject origins = dataw.data["origins"].toObject();
if(dataw.data.contains("_id")) {
origins["name"] = dataw.data["_id"];
@@ -150,12 +149,12 @@ class EntityTreeWidgetItem : public QTreeWidgetItem
setText(2,origins["generation"].toString());
}
- EntityTreeWidgetItem(QVariantMap genomeMap)
+ EntityTreeWidgetItem(QJsonObject genomeMap)
{
dataw.data = genomeMap;
dataw.r = NULL;
- QVariantMap origins = dataw.data["origins"].toMap();
+ QJsonObject origins = dataw.data["origins"].toObject();
if(dataw.data.contains("_id")) {
origins["name"] = dataw.data["_id"];
diff --git a/src/genecraft/core/ui/widgets/experiments/ressourcesbrowser.cpp b/src/genecraft/core/ui/widgets/experiments/ressourcesbrowser.cpp
index 4b31410..702ed0f 100644
--- a/src/genecraft/core/ui/widgets/experiments/ressourcesbrowser.cpp
+++ b/src/genecraft/core/ui/widgets/experiments/ressourcesbrowser.cpp
@@ -100,8 +100,8 @@ RessourcesBrowser::~RessourcesBrowser()
void RessourcesBrowser::connectToInspectorInputManager(GeneCraftCore::InspectorsInputManager * iim) {
connect(this,SIGNAL(sLoadExperiment(Experiment*)),iim,SLOT(loadExperiment(Experiment*)));
- connect(this,SIGNAL(sLoadWorld(QVariantMap)),iim,SLOT(loadWorld(QVariantMap)));
- connect(this,SIGNAL(sLoadEntity(QVariantMap, Ressource*)),iim,SLOT(loadEntity(QVariantMap, Ressource*)));
+ connect(this,SIGNAL(sLoadWorld(QJsonObject)),iim,SLOT(loadWorld(QJsonObject)));
+ connect(this,SIGNAL(sLoadEntity(QJsonObject, Ressource*)),iim,SLOT(loadEntity(QJsonObject, Ressource*)));
connect(iim,SIGNAL(sExperimentUpdated(Experiment*)),this,SLOT(experimentUpdated(Experiment*)));
}
@@ -282,7 +282,7 @@ void RessourcesBrowser::saveEntity() {
EntityTreeWidgetItem *entityTWI = (EntityTreeWidgetItem *) ui->twOnlineEntities->currentItem();
- QVariantMap origins = entityTWI->dataw.data["origins"].toMap();
+ QJsonObject origins = entityTWI->dataw.data["origins"].toObject();
QString selectedFile = QString("./ressources/") + QString(origins["name"].toString()) + QString(".genome");
// file already exists ?
@@ -322,8 +322,8 @@ void RessourcesBrowser::shareExperiment()
// Load Generic Entity
Ressource* to = new DbRecord(database, expTWI->dataw.data["_id"].toString());
- QVariant load = to->load();
- if(load.toMap().contains("error")) {
+ QJsonObject load = to->load();
+ if(load.contains("error")) {
to->save(expTWI->dataw.data);
refreshOnlineRessources();
} else {
@@ -345,8 +345,8 @@ void RessourcesBrowser::shareWorld()
WorldTreeWidgetItem *worldTWI = (WorldTreeWidgetItem *) ui->twLocalWorlds->currentItem();
Ressource* to = new DbRecord(database, worldTWI->dataw.data["name"].toString());
- QVariant load = to->load();
- if(load.toMap().contains("error")) {
+ QJsonObject load = to->load();
+ if(load.contains("error")) {
to->save(worldTWI->dataw.data);
refreshOnlineRessources();
} else {
@@ -374,15 +374,15 @@ void RessourcesBrowser::shareEntity()
// Load Generic Entity
Ressource* to = new DbRecord(database, id);
- QVariantMap creatureData = expTWI->dataw.data;
- QVariantMap origins = creatureData["origins"].toMap();
+ QJsonObject creatureData = expTWI->dataw.data;
+ QJsonObject origins = creatureData["origins"].toObject();
//qDebug() << creatureData["origins"].toMap();
origins.insert("name", id);
creatureData.insert("origins", origins);
//qDebug() << creatureData["origins"].toMap();
- QVariant load = to->load();
- if(load.toMap().contains("error")) {
+ QJsonObject load = to->load();
+ if(load.contains("error")) {
to->save(creatureData);
refreshOnlineRessources();
} else {
diff --git a/src/genecraft/core/ui/widgets/experiments/ressourcesbrowser.h b/src/genecraft/core/ui/widgets/experiments/ressourcesbrowser.h
index 5860bfc..10a8620 100644
--- a/src/genecraft/core/ui/widgets/experiments/ressourcesbrowser.h
+++ b/src/genecraft/core/ui/widgets/experiments/ressourcesbrowser.h
@@ -44,8 +44,8 @@ class RessourcesBrowser : public QWidget
signals:
void sLoadExperiment(Experiment *);
- void sLoadWorld(QVariantMap worldData);
- void sLoadEntity(QVariantMap genomeData, Ressource *ressource);
+ void sLoadWorld(QJsonObject worldData);
+ void sLoadEntity(QJsonObject genomeData, Ressource *ressource);
public slots:
diff --git a/src/genecraft/core/ui/widgets/plot/fitnessplot.cpp b/src/genecraft/core/ui/widgets/plot/fitnessplot.cpp
index 62159dc..36f5cf9 100644
--- a/src/genecraft/core/ui/widgets/plot/fitnessplot.cpp
+++ b/src/genecraft/core/ui/widgets/plot/fitnessplot.cpp
@@ -26,7 +26,7 @@ along with Genecraft-Project. If not, see .
#include
#include
#include
-#include
+#include
#include
#include
#include "fitnessplot.h"
@@ -34,8 +34,9 @@ along with Genecraft-Project. If not, see .
#include
#include "entity.h"
#include "experiment.h"
-#include
-#include
+#include
+#include
+#include
namespace GeneCraftCore {
@@ -127,12 +128,12 @@ namespace GeneCraftCore {
setAutoReplot( false );
- canvas()->setBorderRadius( 10 );
+ dynamic_cast(canvas())->setBorderRadius( 10 );
plotLayout()->setAlignCanvasToScales( true );
QwtLegend *legend = new QwtLegend;
- legend->setItemMode( QwtLegend::CheckableItem );
+ legend->setDefaultItemMode( QwtLegendData::Mode::Checkable );
insertLegend( legend, QwtPlot::RightLegend );
/*
@@ -188,13 +189,13 @@ namespace GeneCraftCore {
lastStep = age;
- QScriptValue fitnessVal = fitnessFunc.call();
+ QJSValue fitnessVal = fitnessFunc.call();
float fitness = fitnessVal.toNumber();
- if(isinf(fitness) || isnan(fitness)) {
+ if(qIsInf(fitness) || qIsNaN(fitness)) {
fitness = 0;
}
- QScriptValue endBool = endFunc.call(QScriptValue(), QScriptValueList() << age);
+ QJSValue endBool = endFunc.call(QJSValueList() << age);
bool end = endBool.toBool();
if(end && !ended) {
ended = true;
@@ -234,7 +235,7 @@ namespace GeneCraftCore {
markers << m;
}
- QScriptValue dead = dieFunc.call();
+ QJSValue dead = dieFunc.call();
bool isDead = dead.toBool();
if(isDead && !die) {
die = true;
@@ -264,10 +265,10 @@ namespace GeneCraftCore {
break;
}
}
- if(isnan(min) || isinf(min))
+ if(qIsNaN(min) || qIsInf(min))
min = 0;
- if(isnan(max) || isinf(max))
+ if(qIsNaN(max) || qIsInf(max))
max = 0;
for(int i = 0; i < NB_STAT; i++) {
@@ -282,11 +283,11 @@ namespace GeneCraftCore {
FitnessCurve* c = (FitnessCurve*)curves[i].curve;
if(c->isVisible()) {
- if(min > curves[i].data[j] && !isnan(curves[i].data[j]) && !isinf(curves[i].data[j])) {
+ if(min > curves[i].data[j] && !qIsNaN(curves[i].data[j]) && !qIsInf(curves[i].data[j])) {
min = curves[i].data[j];
}
- if(max < curves[i].data[j] && !isnan(curves[i].data[j]) && !isinf(curves[i].data[j])) {
+ if(max < curves[i].data[j] && !qIsNaN(curves[i].data[j]) && !qIsInf(curves[i].data[j])) {
max = curves[i].data[j];
}
}
@@ -318,7 +319,7 @@ namespace GeneCraftCore {
break;
curves[i].data[0] = ent->getStatisticsStorage()->getStatistics()[s]->getValue();
- if(isnan(curves[i].data[0]) || isinf(curves[i].data[0]))
+ if(qIsNaN(curves[i].data[0]) || qIsInf(curves[i].data[0]))
curves[i].data[0] = 0;
}
@@ -365,11 +366,19 @@ namespace GeneCraftCore {
{
item->setVisible( on );
- QwtLegendItem *legendItem =
- qobject_cast( legend()->find( item ) );
+ QwtLegend *lgd = qobject_cast( legend() );
- if ( legendItem )
- legendItem->setChecked( on );
+ QList legendWidgets =
+ lgd->legendWidgets( itemToInfo( item ) );
+
+ if ( legendWidgets.size() == 1 )
+ {
+ QwtLegendLabel *legendLabel =
+ qobject_cast( legendWidgets[0] );
+
+ if ( legendLabel )
+ legendLabel->setChecked( on );
+ }
replot();
}
@@ -475,7 +484,7 @@ namespace GeneCraftCore {
Statistic* stat = stats[statName];
// Insert a new properties of our top level object
// With the name of the statistic
- QScriptValue statObject = scriptEngine.newQObject(stat);
+ QJSValue statObject = scriptEngine.newQObject(stat);
entityObj.setProperty(statName, statObject);
}
diff --git a/src/genecraft/core/ui/widgets/plot/fitnessplot.h b/src/genecraft/core/ui/widgets/plot/fitnessplot.h
index a098961..bff6aae 100644
--- a/src/genecraft/core/ui/widgets/plot/fitnessplot.h
+++ b/src/genecraft/core/ui/widgets/plot/fitnessplot.h
@@ -21,7 +21,7 @@ along with Genecraft-Project. If not, see .
#define __CPU_PLOT_H_
#include "qwt_plot.h"
#include
-#include
+#include
#include "genecraftcoreclasses.h"
#define HISTORY 1200
#define NB_STAT 14
@@ -72,12 +72,12 @@ namespace GeneCraftCore {
// Scripting
- QScriptEngine scriptEngine;
- QScriptValue entityObj;
- QScriptValue validityFunc;
- QScriptValue endFunc;
- QScriptValue dieFunc;
- QScriptValue fitnessFunc;
+ QJSEngine scriptEngine;
+ QJSValue entityObj;
+ QJSValue validityFunc;
+ QJSValue endFunc;
+ QJSValue dieFunc;
+ QJSValue fitnessFunc;
};
}
diff --git a/src/genecraft/core/world/bullet/btbiome.cpp b/src/genecraft/core/world/bullet/btbiome.cpp
index faa7c70..210d44a 100644
--- a/src/genecraft/core/world/bullet/btbiome.cpp
+++ b/src/genecraft/core/world/bullet/btbiome.cpp
@@ -21,11 +21,10 @@ along with Genecraft-Project. If not, see .
#include "btworld.h"
namespace GeneCraftCore {
- btBiome::btBiome(btWorld* world, QVariant biomeData, QObject *parent) :
+ btBiome::btBiome(btWorld* world, QJsonObject data, QObject *parent) :
QObject(parent)
{
world->setBiome(this);
- this->data = biomeData.toMap();
}
btBiome::~btBiome() {
@@ -33,7 +32,7 @@ namespace GeneCraftCore {
}
void btBiome::setup() {
- btScalar gravity = data["gravity"].toFloat();
+ btScalar gravity = data["gravity"].toDouble();
world->setGravity(btVector3(0,-gravity,0));
}
diff --git a/src/genecraft/core/world/bullet/btbiome.h b/src/genecraft/core/world/bullet/btbiome.h
index 033938f..77b8fcf 100644
--- a/src/genecraft/core/world/bullet/btbiome.h
+++ b/src/genecraft/core/world/bullet/btbiome.h
@@ -21,7 +21,7 @@ along with Genecraft-Project. If not, see .
#define BTBIOME_H
#include
-#include
+#include
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
#include "btfactory.h"
@@ -31,7 +31,7 @@ namespace GeneCraftCore {
class btBiome : public QObject
{
public:
- explicit btBiome(btWorld* world, QVariant biomeData, QObject *parent = 0);
+ explicit btBiome(btWorld* world, QJsonObject biomeData, QObject *parent = 0);
~btBiome();
virtual void setup();
@@ -41,7 +41,7 @@ class btBiome : public QObject
}
protected:
- QVariantMap data;
+ QJsonObject data;
btDynamicsWorld* world;
};
diff --git a/src/genecraft/core/world/bullet/btscene.cpp b/src/genecraft/core/world/bullet/btscene.cpp
index 24768f5..dd88e62 100644
--- a/src/genecraft/core/world/bullet/btscene.cpp
+++ b/src/genecraft/core/world/bullet/btscene.cpp
@@ -31,21 +31,22 @@ along with Genecraft-Project. If not, see .
#include "tools.h"
#include "btworldfactory.h"
+#include
namespace GeneCraftCore {
double test[129*129];
- btScene::btScene(btWorld* world, QVariant sceneData, QObject *parent) :
+ btScene::btScene(btWorld* world, QJsonObject sceneData, QObject *parent) :
QObject(parent)
{
this->world = world;
this->world->setScene(this);
- this->data = sceneData.toMap();
- QVariantList spawnData = data["spawns"].toList();
+ this->data = sceneData;
+ QJsonArray spawnData = data["spawns"].toArray();
- foreach(QVariant v, spawnData) {
- this->spawns.append(new Spawn(v));
+ foreach(QJsonValue v, spawnData) {
+ this->spawns.append(new Spawn(v.toObject()));
}
if(this->spawns.size() == 0) { // Prevent no spawn bug !
@@ -81,9 +82,9 @@ namespace GeneCraftCore {
void btScene::setup() {
- QVariantMap floor = data["floor"].toMap();
+ QJsonObject floor = data["floor"].toObject();
- QVariantList staticShapesList = data.value("shapes").toList();
+ QJsonArray staticShapesList = data.value("shapes").toArray();
//floor["type"] = "randomBoxes";
// Add the entry to the terrain engine
@@ -118,9 +119,9 @@ namespace GeneCraftCore {
if(data.contains("shapes")){
- foreach(QVariant shapeData, staticShapesList)
+ foreach(QJsonValue shapeData, staticShapesList)
{
- QVariantMap shapeMap = shapeData.toMap();
+ QJsonObject shapeMap = shapeData.toObject();
QString type = shapeMap["type"].toString();
if(type.compare("box") == 0) {
@@ -134,7 +135,7 @@ namespace GeneCraftCore {
btVector3 size(shapeMap.value("sizeX").toDouble(),shapeMap.value("sizeY").toDouble(),shapeMap.value("sizeZ").toDouble());
// create the box
- btBox *box = world->getShapesFactory()->createBox(size, transform, shapeMap["density"].toFloat());
+ btBox *box = world->getShapesFactory()->createBox(size, transform, shapeMap["density"].toDouble());
box->setup();
shapes.append(box);
@@ -147,7 +148,7 @@ namespace GeneCraftCore {
transform.getBasis().setEulerZYX(shapeMap.value("eulerX").toDouble(),shapeMap.value("eulerY").toDouble(),shapeMap.value("eulerZ").toDouble());
// create the box
- btSphere *sphere = world->getShapesFactory()->createSphere(shapeMap.value("radius").toFloat(), transform, shapeMap["density"].toFloat());
+ btSphere *sphere = world->getShapesFactory()->createSphere(shapeMap.value("radius").toDouble(), transform, shapeMap["density"].toDouble());
sphere->setup();
shapes.append(sphere);
}
@@ -159,7 +160,11 @@ namespace GeneCraftCore {
transform.getBasis().setEulerZYX(shapeMap.value("eulerX").toDouble(),shapeMap.value("eulerY").toDouble(),shapeMap.value("eulerZ").toDouble());
// create the box
- btCylinder *cylinder = world->getShapesFactory()->createCylinder(shapeMap.value("radius").toFloat(), shapeMap.value("height").toFloat(), transform, shapeMap["density"].toFloat());
+ btCylinder *cylinder = world->getShapesFactory()->createCylinder(
+ shapeMap.value("radius").toDouble(),
+ shapeMap.value("height").toDouble(),
+ transform,
+ shapeMap["density"].toDouble());
cylinder->setup();
shapes.append(cylinder);
}
diff --git a/src/genecraft/core/world/bullet/btscene.h b/src/genecraft/core/world/bullet/btscene.h
index 3923ca7..2dbcb8c 100644
--- a/src/genecraft/core/world/bullet/btscene.h
+++ b/src/genecraft/core/world/bullet/btscene.h
@@ -21,7 +21,7 @@ along with Genecraft-Project. If not, see .
#define BTSCENE_H
#include
-#include
+#include
#include "spawn.h"
#include "genecraftcoreclasses.h"
@@ -41,7 +41,7 @@ class btScene : public QObject
{
public:
- explicit btScene(btWorld* world, QVariant sceneData, QObject *parent = 0);
+ explicit btScene(btWorld* world, QJsonObject sceneData, QObject *parent = 0);
~btScene();
virtual void setup();
@@ -53,7 +53,7 @@ class btScene : public QObject
}
protected:
- QVariantMap data;
+ QJsonObject data;
btDynamicsWorld* bulletWorld;
btWorld* world;
QList spawns;
diff --git a/src/genecraft/core/world/bullet/btworld.cpp b/src/genecraft/core/world/bullet/btworld.cpp
index 6f0abd8..bb67465 100644
--- a/src/genecraft/core/world/bullet/btworld.cpp
+++ b/src/genecraft/core/world/bullet/btworld.cpp
@@ -45,7 +45,7 @@ namespace GeneCraftCore {
QObject(parent)
{
// TODO
- this->data = QVariantMap();
+ this->data = QJsonObject();
this->factory = factory;
this->shapesFactory = shapesFactory;
this->btEngine = static_cast(factory->getEngineByName("Bullet"));
@@ -53,10 +53,9 @@ namespace GeneCraftCore {
}
- btWorld::btWorld(btFactory* factory, btShapesFactory* shapesFactory, QVariant worldData, QObject *parent) :
+ btWorld::btWorld(btFactory* factory, btShapesFactory* shapesFactory, QJsonObject data, QObject *parent) :
QObject(parent)
{
- this->data = worldData.toMap();
this->factory = factory;
this->shapesFactory = shapesFactory;
this->btEngine = static_cast(factory->getEngineByName("Bullet"));
diff --git a/src/genecraft/core/world/bullet/btworld.h b/src/genecraft/core/world/bullet/btworld.h
index f66c727..2efa149 100644
--- a/src/genecraft/core/world/bullet/btworld.h
+++ b/src/genecraft/core/world/bullet/btworld.h
@@ -26,7 +26,7 @@ along with Genecraft-Project. If not, see .
#include
#include
-#include
+#include
#include "bullet/btscene.h"
#include "bullet/btbiome.h"
@@ -43,7 +43,7 @@ namespace GeneCraftCore {
btWorld(btFactory* factory, btShapesFactory* shapesFactory, QObject *parent = 0);
// To create a world from serialization data
- btWorld(btFactory* factory, btShapesFactory* shapesFactory, QVariant worldData, QObject *parent = 0);
+ btWorld(btFactory* factory, btShapesFactory* shapesFactory, QJsonObject worldData, QObject *parent = 0);
~btWorld();
// To create a new creature
@@ -96,7 +96,7 @@ namespace GeneCraftCore {
btSequentialImpulseConstraintSolver* solver;
// Data
- QVariantMap data;
+ QJsonObject data;
};
}
diff --git a/src/genecraft/core/world/bulletogre/btobiome.cpp b/src/genecraft/core/world/bulletogre/btobiome.cpp
index 8aff506..bcb1d50 100644
--- a/src/genecraft/core/world/bulletogre/btobiome.cpp
+++ b/src/genecraft/core/world/bulletogre/btobiome.cpp
@@ -26,22 +26,20 @@ along with Genecraft-Project. If not, see .
#include "bulletogre/bulletogreengine.h"
#include "ogre/ogreengine.h"
-#include
-#include
-#include
+#include
+#include
#include "btofactory.h"
#include