Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

python api: expose ScenePtr.get() (boost::shared_ptr<Scene>.get()) so…

… *Raw funcs are not needed. instead needs a .get() call after thing like scene.GetEntityByName() but perhaps that is ok? don't know a way to autoconvert, at least in the c++ side, pythonqt doesn't seem to have that feature? if this is considered nice, can add EntityPtr.get() and ComponentPtr.get() etc. trivially
  • Loading branch information...
commit e72cb827c7fcbaee27b8258e616ee7bd2835fbd7 1 parent aa90b42
antont authored
View
2  bin/pyplugins/websocketserver/websocketserver.py
@@ -41,7 +41,7 @@ def on_sceneadded(name):
'''Connects to various signal when scene is added'''
global scene
sceneapi = tundra.Scene()
- scene = sceneapi.GetSceneRaw(name)
+ scene = sceneapi.GetScene(name).get() #*Raw
print "Using scene:", scene.name, scene
assert scene.connect("AttributeChanged(IComponent*, IAttribute*, AttributeChange::Type)", onAttributeChanged)
View
27 src/Application/PythonScriptModule/TundraWrapper.cpp
@@ -1,6 +1,7 @@
// For conditions of distribution and use, see copyright notice in LICENSE
#include "StableHeaders.h"
+//#include <boost/smart_ptr.hpp> //tried to make a generic Ptr exposer but failed, registering Scene, Entity, Component separately
#include "TundraWrapper.h"
#include "SceneAPI.h"
@@ -36,23 +37,12 @@ namespace PythonScript
return compSharedPtr.get();
}
- /*QObject* TundraInstanceDecorator::get(ScenePtr self)
- {
- return self.get();
- }
- */
QObject *TundraInstanceDecorator::GetSceneRaw(SceneAPI *sceneapi, const QString &scenename)
{
return sceneapi->GetScene(scenename).get();
}
- // TundraDecorator
-
- /*QObject* TundraDecorator::get(ScenePtr self)
- {
- return self.get();
- }*/
AssetReference *TundraDecorator::new_AssetReference()
{
@@ -179,4 +169,19 @@ namespace PythonScript
{
return self->SetFromAxisAngle(rotationAxis, rotationAngleRadians);
}
+
+ //Ptr conversions, not automatic but with an explicit call
+ int scenePtr_id = qRegisterMetaType<ScenePtr>("ScenePtr");
+ QObject* TundraDecorator::get(ScenePtr* self)
+ {
+ return self->get();
+ }
+
+ /* couldn't get this working, dunno if is possible even. templates are just automated copy-paste so perhaps not big deal?
+ int sharedPtr_id = qRegisterMetaType<boost::shared_ptr>("shared_ptr");
+ template<typename T>
+ QObject* TundraDecorator::get(const boost::shared_ptr<T> &self)
+ {
+ return self->get();
+ }*/
}
View
12 src/Application/PythonScriptModule/TundraWrapper.h
@@ -2,6 +2,7 @@
#pragma once
+//#include <boost/smart_ptr.hpp>
#include "PythonFwd.h"
#include "Math/float3.h"
#include "Transform.h"
@@ -24,7 +25,6 @@ namespace PythonScript
QObject *CreateEntityLocalRaw(Scene *scene, const QStringList &components = QStringList(), AttributeChange::Type change = AttributeChange::LocalOnly, bool defaultNetworkSync = false);
QObject *GetEntityByNameRaw(Scene *scene, const QString &name);
- // SceneAPI too..
QObject *GetSceneRaw(SceneAPI *sceneapi, const QString &scenename);
// Entity: Member functions, this is a knows QObject for PythonQt, we are adding functionality to the existing object.
@@ -44,8 +44,6 @@ namespace PythonScript
Q_OBJECT
public slots:
- //QObject *get(ScenePtr self); //if can't autoconvert boost pointers, perhaps can make a generic raw pointer getter?
-
// AssetReference: Construct and destruct
AssetReference *new_AssetReference();
AssetReference *new_AssetReference(const QString &reference);
@@ -87,6 +85,14 @@ namespace PythonScript
//setters for Quat
void SetFromAxisAngle(Quat* self, const float3 &rotationAxis, const float rotationAngleRadians);
Quat FromEulerZYX(Quat* self, float z, float y, float x) const;
+
+ QObject* get(ScenePtr* self);
+
+ /* this failed so far
+ public:
+ template<typename T>
+ QObject* get(const boost::shared_ptr<T> &self); //if can't autoconvert boost pointers, perhaps can make a generic raw pointer getter?*/
+
};
/** @endcond */
}
Please sign in to comment.
Something went wrong with that request. Please try again.