Revision: 31234
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31234
Author:   nexyon
Date:     2010-08-11 12:36:16 +0200 (Wed, 11 Aug 2010)

Log Message:
-----------
Blender Py API: Implemented missing KX_PYATTRIBUTE_TODOs and -DUMMYs.

Modified Paths:
--------------
    branches/soc-2010-nexyon/source/gameengine/Expressions/PyObjectPlus.h
    branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_ISensor.cpp
    branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_ISensor.h
    branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
    branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
    branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_BlenderMaterial.h
    branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
    branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_ConstraintWrapper.h
    branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_PolyProxy.cpp
    branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_PolyProxy.h
    branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_VertexProxy.cpp
    branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_VertexProxy.h

Modified: branches/soc-2010-nexyon/source/gameengine/Expressions/PyObjectPlus.h
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/Expressions/PyObjectPlus.h       
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/Expressions/PyObjectPlus.h       
2010-08-11 10:36:16 UTC (rev 31234)
@@ -319,9 +319,6 @@
        } m_typeCheck;
 } PyAttributeDef;
 
-#define KX_PYATTRIBUTE_DUMMY(name) \
-       { name, KX_PYATTRIBUTE_TYPE_DUMMY, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, 
false, false, 0, 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, 
NULL} }
-
 #define KX_PYATTRIBUTE_BOOL_RW(name,object,field) \
        { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, 
false, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {&((object 
*)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} }
 #define KX_PYATTRIBUTE_BOOL_RW_CHECK(name,object,field,function) \

Modified: branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_ISensor.cpp
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_ISensor.cpp        
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_ISensor.cpp        
2010-08-11 10:36:16 UTC (rev 31234)
@@ -357,9 +357,8 @@
        KX_PYATTRIBUTE_RO_FUNCTION("triggered", SCA_ISensor, 
pyattr_get_triggered),
        KX_PYATTRIBUTE_RO_FUNCTION("positive", SCA_ISensor, 
pyattr_get_positive),
        KX_PYATTRIBUTE_RO_FUNCTION("status", SCA_ISensor, pyattr_get_status),
-       //KX_PYATTRIBUTE_TODO("links"),
-       //KX_PYATTRIBUTE_TODO("posTicks"),
-       //KX_PYATTRIBUTE_TODO("negTicks"),
+       KX_PYATTRIBUTE_RO_FUNCTION("pos_ticks", SCA_ISensor, 
pyattr_get_posTicks),
+       KX_PYATTRIBUTE_RO_FUNCTION("neg_ticks", SCA_ISensor, 
pyattr_get_negTicks),
        { NULL }        //Sentinel
 };
 
@@ -401,6 +400,18 @@
        return PyLong_FromSsize_t(status);
 }
 
+PyObject* SCA_ISensor::pyattr_get_posTicks(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef)
+{
+       SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);
+       return PyLong_FromLong(self->GetPosTicks());
+}
+
+PyObject* SCA_ISensor::pyattr_get_negTicks(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef)
+{
+       SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);
+       return PyLong_FromLong(self->GetNegTicks());
+}
+
 int SCA_ISensor::pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF 
*attrdef)
 {
        SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);

Modified: branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_ISensor.h
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_ISensor.h  
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_ISensor.h  
2010-08-11 10:36:16 UTC (rev 31234)
@@ -167,6 +167,18 @@
                return m_prev_state;
        }
 
+       /** get the number of ticks since the last positive pulse */
+       int GetPosTicks()
+       {
+               return m_pos_ticks;
+       }
+
+       /** get the number of ticks since the last negative pulse */
+       int GetNegTicks()
+       {
+               return m_neg_ticks;
+       }
+
        /** Resume sensing. */
        void Resume();
 
@@ -185,6 +197,9 @@
        static PyObject*        pyattr_get_triggered(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
        static PyObject*        pyattr_get_positive(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
        static PyObject*        pyattr_get_status(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
+       static PyObject*        pyattr_get_posTicks(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
+       static PyObject*        pyattr_get_negTicks(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
+
        static int          pyattr_check_level(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
        static int          pyattr_check_tap(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
        

Modified: 
branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_JoystickSensor.cpp 
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/GameLogic/SCA_JoystickSensor.cpp 
2010-08-11 10:36:16 UTC (rev 31234)
@@ -290,7 +290,6 @@
        KX_PYATTRIBUTE_RO_FUNCTION("numButtons",        SCA_JoystickSensor, 
pyattr_get_num_buttons),
        KX_PYATTRIBUTE_RO_FUNCTION("numHats",           SCA_JoystickSensor, 
pyattr_get_num_hats),
        KX_PYATTRIBUTE_RO_FUNCTION("connected",         SCA_JoystickSensor, 
pyattr_get_connected),
-       //KX_PYATTRIBUTE_TODO("events"),
        { NULL }        //Sentinel
 };
 

Modified: 
branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_BlenderMaterial.cpp    
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_BlenderMaterial.cpp    
2010-08-11 10:36:16 UTC (rev 31234)
@@ -794,9 +794,9 @@
 };
 
 PyAttributeDef KX_BlenderMaterial::Attributes[] = {
-       //KX_PYATTRIBUTE_TODO("shader"),
-       //KX_PYATTRIBUTE_TODO("materialIndex"),
-       //KX_PYATTRIBUTE_TODO("blending"),
+       KX_PYATTRIBUTE_RO_FUNCTION("shader", KX_BlenderMaterial, 
pyattr_get_shader),
+       KX_PYATTRIBUTE_RO_FUNCTION("material_index", KX_BlenderMaterial, 
pyattr_get_materialIndex),
+       KX_PYATTRIBUTE_RW_FUNCTION("blending", KX_BlenderMaterial, 
pyattr_get_blending, pyattr_set_blending),
        { NULL }        //Sentinel
 };
 
@@ -822,6 +822,37 @@
        py_base_new
 };
 
+PyObject* KX_BlenderMaterial::pyattr_get_shader(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef)
+{
+       KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v);
+       return self->PygetShader(NULL, NULL);
+}
+
+PyObject* KX_BlenderMaterial::pyattr_get_materialIndex(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef)
+{
+       KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v);
+       return PyLong_FromSsize_t(self->GetMaterialIndex());
+}
+
+PyObject* KX_BlenderMaterial::pyattr_get_blending(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef)
+{
+       KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v);
+       unsigned int* bfunc = self->getBlendFunc();
+       return Py_BuildValue("(ll)", (long int)bfunc[0], (long int)bfunc[1]);
+}
+
+int KX_BlenderMaterial::pyattr_set_blending(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+       KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v);
+       PyObject* obj = self->PysetBlending(value, NULL);
+       if(obj)
+       {
+               Py_DECREF(obj);
+               return 0;
+       }
+       return -1;
+}
+
 KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
 {
        if( !GLEW_ARB_fragment_shader) {

Modified: branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_BlenderMaterial.h
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_BlenderMaterial.h      
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_BlenderMaterial.h      
2010-08-11 10:36:16 UTC (rev 31234)
@@ -79,6 +79,9 @@
        Image * getImage (unsigned int idx) { 
                return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : 
NULL; 
        }
+       unsigned int* getBlendFunc() {
+               return mBlendFunc;
+       }
        // for ipos
        void UpdateIPO(
                MT_Vector4 rgba, MT_Vector3 specrgb,
@@ -99,6 +102,11 @@
        // --------------------------------
        virtual PyObject* py_repr(void) { return 
PyUnicode_FromString(mMaterial->matname.ReadPtr()); }
 
+       static PyObject* pyattr_get_shader(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
+       static PyObject* pyattr_get_materialIndex(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
+       static PyObject* pyattr_get_blending(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
+       static int       pyattr_set_blending(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+
        KX_PYMETHOD_DOC( KX_BlenderMaterial, getShader );
        KX_PYMETHOD_DOC( KX_BlenderMaterial, getMaterialIndex );
        KX_PYMETHOD_DOC( KX_BlenderMaterial, getTexture );

Modified: 
branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp  
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp  
2010-08-11 10:36:16 UTC (rev 31234)
@@ -110,8 +110,14 @@
 };
 
 PyAttributeDef KX_ConstraintWrapper::Attributes[] = {
-       //KX_PYATTRIBUTE_TODO("constraintId"),
+       KX_PYATTRIBUTE_RO_FUNCTION("constraint_id", KX_ConstraintWrapper, 
pyattr_get_constraintId),
        { NULL }        //Sentinel
 };
 
+PyObject* KX_ConstraintWrapper::pyattr_get_constraintId(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef)
+{
+       KX_ConstraintWrapper* self= static_cast<KX_ConstraintWrapper*>(self_v);
+       return self->PyGetConstraintId();
+}
+
 #endif // DISABLE_PYTHON

Modified: 
branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_ConstraintWrapper.h
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_ConstraintWrapper.h    
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_ConstraintWrapper.h    
2010-08-11 10:36:16 UTC (rev 31234)
@@ -44,6 +44,8 @@
        KX_PYMETHOD_NOARGS(KX_ConstraintWrapper,GetConstraintId);
        KX_PYMETHOD(KX_ConstraintWrapper,SetParam);
        KX_PYMETHOD(KX_ConstraintWrapper,GetParam);
+
+       static PyObject* pyattr_get_constraintId(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
 #endif
 
 private:

Modified: branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_PolyProxy.cpp
===================================================================
--- branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_PolyProxy.cpp  
2010-08-11 08:23:48 UTC (rev 31233)
+++ branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_PolyProxy.cpp  
2010-08-11 10:36:16 UTC (rev 31234)
@@ -72,90 +72,19 @@
 };
 
 PyAttributeDef KX_PolyProxy::Attributes[] = {
-       /* All dummy's so they come up in a dir() */
-       //KX_PYATTRIBUTE_TODO("DummyProps"),
-       KX_PYATTRIBUTE_DUMMY("matname"),
-       KX_PYATTRIBUTE_DUMMY("texture"),
-       KX_PYATTRIBUTE_DUMMY("material"),
-       KX_PYATTRIBUTE_DUMMY("matid"),
-       KX_PYATTRIBUTE_DUMMY("v1"),
-       KX_PYATTRIBUTE_DUMMY("v2"),
-       KX_PYATTRIBUTE_DUMMY("v3"),
-       KX_PYATTRIBUTE_DUMMY("v4"),
-       KX_PYATTRIBUTE_DUMMY("visible"),
-       KX_PYATTRIBUTE_DUMMY("collide"),
+       KX_PYATTRIBUTE_RO_FUNCTION("material_name", KX_PolyProxy, 
pyattr_get_material_name),

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to