Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-04-19 16:46:39 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-19 16:46:39 +0400
commit8d2cb5bea44f4245dd17f2d82cbd0251d8090fd5 (patch)
treeb28e45f1edaf083c15d2176079836a4497685e57 /source/gameengine/VideoTexture
parent92cea7c1b1540d11ed9729bacfabd23ccb7a79c7 (diff)
BGE Python API
This changes how the BGE classes and Python work together, which hasnt changed since blender went opensource. The main difference is PyObjectPlus - the base class for most game engine classes, no longer inherit from PyObject, and cannot be cast to a PyObject. This has the advantage that the BGE does not have to keep 2 reference counts valid for C++ and Python. Previously C++ classes would never be freed while python held a reference, however this reference could be problematic eg: a GameObject that isnt in a scene anymore should not be used by python, doing so could even crash blender in some cases. Instead PyObjectPlus has a member "PyObject *m_proxy" which is lazily initialized when python needs it. m_proxy reference counts are managed by python, though it should never be freed while the C++ class exists since it holds a reference to avoid making and freeing it all the time. When the C++ class is free'd it sets the m_proxy reference to NULL, If python accesses this variable it will raise a RuntimeError, (check the isValid attribute to see if its valid without raising an error). - This replaces the m_zombie bool and IsZombie() tests added recently. In python return values that used to be.. return value->AddRef(); Are now return value->GetProxy(); or... return value->NewProxy(true); // true means python owns this C++ value which will be deleted when the PyObject is freed
Diffstat (limited to 'source/gameengine/VideoTexture')
-rw-r--r--source/gameengine/VideoTexture/FilterSource.h3
-rw-r--r--source/gameengine/VideoTexture/ImageRender.cpp23
2 files changed, 18 insertions, 8 deletions
diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h
index 6385ed5108f..254e0a02679 100644
--- a/source/gameengine/VideoTexture/FilterSource.h
+++ b/source/gameengine/VideoTexture/FilterSource.h
@@ -225,7 +225,7 @@ protected:
// otherwise if only vertical interpolation is needed
}
}
- else if ((y & 1) == 1)
+ else if ((y & 1) == 1) {
// if this pixel is on the edge
if (isEdge(x, y, size))
{
@@ -239,6 +239,7 @@ protected:
d = interpolV(m_buffU + offset) - 128;
e = interpolV(m_buffV + offset) - 128;
}
+ }
// convert to RGB
// R = clip(( 298 * C + 409 * E + 128) >> 8)
// G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8)
diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp
index 6ef62f64d3f..9a3c4fea70e 100644
--- a/source/gameengine/VideoTexture/ImageRender.cpp
+++ b/source/gameengine/VideoTexture/ImageRender.cpp
@@ -434,26 +434,35 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds
{
// get scene pointer
KX_Scene * scenePtr (NULL);
- if (scene != NULL && PyObject_TypeCheck(scene, &KX_Scene::Type))
- scenePtr = static_cast<KX_Scene*>(scene);
- else
+ if (scene != NULL && PyObject_TypeCheck(scene, &KX_Scene::Type))
+ scenePtr = static_cast<KX_Scene*>BGE_PROXY_REF(scene);
+ else
THRWEXCP(SceneInvalid, S_OK);
-
+
+ if(scenePtr==NULL) /* incase the python proxy reference is invalid */
+ THRWEXCP(SceneInvalid, S_OK);
+
// get observer pointer
KX_GameObject * observerPtr (NULL);
if (observer != NULL && PyObject_TypeCheck(observer, &KX_GameObject::Type))
- observerPtr = static_cast<KX_GameObject*>(observer);
+ observerPtr = static_cast<KX_GameObject*>BGE_PROXY_REF(observer);
else if (observer != NULL && PyObject_TypeCheck(observer, &KX_Camera::Type))
- observerPtr = static_cast<KX_Camera*>(observer);
+ observerPtr = static_cast<KX_Camera*>BGE_PROXY_REF(observer);
else
THRWEXCP(ObserverInvalid, S_OK);
+
+ if(observerPtr==NULL) /* incase the python proxy reference is invalid */
+ THRWEXCP(ObserverInvalid, S_OK);
// get mirror pointer
KX_GameObject * mirrorPtr (NULL);
if (mirror != NULL && PyObject_TypeCheck(mirror, &KX_GameObject::Type))
- mirrorPtr = static_cast<KX_GameObject*>(mirror);
+ mirrorPtr = static_cast<KX_GameObject*>BGE_PROXY_REF(mirror);
else
THRWEXCP(MirrorInvalid, S_OK);
+
+ if(mirrorPtr==NULL) /* incase the python proxy reference is invalid */
+ THRWEXCP(MirrorInvalid, S_OK);
// locate the material in the mirror
RAS_IPolyMaterial * material = getMaterial(mirror, materialID);