Minor Fixes:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Sat, 26 Jun 2004 09:15:41 +0000 (09:15 +0000)
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Sat, 26 Jun 2004 09:15:41 +0000 (09:15 +0000)
Better use of booleans for python
#include fixes for Windows
Python Doc fixes
Use the farthest vertex as the face position when z sorting faces. (Camera is on -z axis!)

14 files changed:
source/gameengine/GameLogic/SCA_ILogicBrick.cpp
source/gameengine/GameLogic/SCA_RandomActuator.cpp
source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/Ketsji/KX_Scene.h
source/gameengine/Ketsji/KX_SceneActuator.cpp
source/gameengine/Ketsji/KX_TouchSensor.cpp
source/gameengine/PyDoc/GameKeys.py
source/gameengine/PyDoc/GameLogic.py
source/gameengine/PyDoc/KX_Camera.py
source/gameengine/PyDoc/KX_Scene.py
source/gameengine/PyDoc/SCA_KeyboardSensor.py
source/gameengine/Rasterizer/RAS_MaterialBucket.h
source/gameengine/Rasterizer/RAS_MeshObject.cpp

index 422f6d9cf0d3d224dd631115b51d57bed6a1d03c..1780458ba45abcce2b9c500ade7991679c9c3bea 100644 (file)
@@ -309,12 +309,9 @@ PyObject* SCA_ILogicBrick::PyGetExecutePriority(PyObject* self,
 /* Conversions for making life better. */
 bool SCA_ILogicBrick::PyArgToBool(int boolArg)
 {
-       if (boolArg == KX_TRUE) {
+       if (boolArg) {
                return true;
-       } else if (boolArg == KX_FALSE){
-               return false;
        } else {
-               ; /* error: bad conversion: how to catch this? */
                return false;
        }
 }
index d483f40006407e94b7f7d54ab2e04c907f4fe459..b4a28291e669a9f802998f87631c9f199ea04f3e 100644 (file)
@@ -464,7 +464,7 @@ PyObject* SCA_RandomActuator::PySetBoolConst(PyObject* self,
        }
        
        m_distribution = KX_RANDOMACT_BOOL_CONST;
-       if (paraArg == KX_TRUE) {
+       if (paraArg) {
                m_parameter1 = 1;
        }
        
index 472d921dbe9b52bf4db4ef9e5169b251fa2f4a6f..c4715c5f060625a69eace8f77e442f174819cf24 100644 (file)
 #include <config.h>
 #endif
 
+#ifdef WIN32
+#include <windows.h>
+#endif // WIN32
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
+#include <GL/gl.h>
+#include <GL/glu.h>
+#endif
+
+
+
 #include "GPC_PolygonMaterial.h"
 #include "MT_Vector3.h"
 #include "RAS_IRasterizer.h"
 #include "IMB_imbuf_types.h"
 /* end of blender include block */
 
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#ifdef __APPLE__
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#include <GL/glu.h>
-#endif
-
 static Image *fCurpage=0;
 static int fCurtile=0, fCurmode=0, fCurTileXRep=0, fCurTileYRep=0;
 static short fTexWindx, fTexWindy, fTexWinsx, fTexWinsy;
index 868f9f1ea403d52dbef0ffc8614a4f42d597c01b..48859392b54d36108916bfe00c3150da58357809 100644 (file)
 
 #ifdef WIN32
        #pragma warning (disable:4786) // suppress stl-MSVC debug info warning
+       #include <windows.h>
+#endif
+
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
+#include <GL/gl.h>
+#include <GL/glu.h>
 #endif
 
 #include "GPG_Application.h"
index c32cd4182aa087b5c45d8ea94a6fab9d757bdd7e..1df126ce1b09cdf12e6ee634773170d75ebd4ff8 100644 (file)
 struct SM_MaterialProps;
 struct SM_ShapeProps;
 
+class GEN_HashedPtr;
 class CListValue;
-class RAS_BucketManager;
-class KX_Camera;
+class CValue;
 class SCA_LogicManager;
 class SCA_KeyboardManager;
 class SCA_TimeEventManager;
 class SCA_MouseManager;
-class KX_WorldInfo;
+class SCA_ISystem;
+class SCA_IInputDevice;
 class SND_Scene;
 class SND_IAudioDevice;
 class NG_NetworkDeviceInterface;
 class NG_NetworkScene;
+class SG_IObject;
 class SG_Node;
 class SG_Tree;
+class KX_WorldInfo;
 class KX_Camera;
-class GEN_HashedPtr;
 class KX_GameObject;
-class SCA_ISystem;
-class SCA_IInputDevice;
+class KX_LightObject;
+class RAS_BucketManager;
 class RAS_BucketManager;
 class RAS_MaterialBucket;
 class RAS_IPolyMaterial;
 class RAS_IRasterizer;
 class RAS_IRenderTools;
-class CValue;
-class SG_IObject;
 
 /**
  * The KX_Scene holds all data for an independent scene. It relates
  * KX_Objects to the specific objects in the modules.
  * */
-class KX_Scene : public SCA_IScene, public PyObjectPlus
+class KX_Scene : public PyObjectPlus, public SCA_IScene
 {
        Py_Header;
 protected:
index 996b671094a1ddb4b8977ec217ccb573bceeab6d..721d01a3da353abf9e34f3eb93585305d9f49929 100644 (file)
@@ -247,18 +247,7 @@ PyObject* KX_SceneActuator::PySetUseRestart(PyObject* self,
                return NULL;
        }
        
-       if (boolArg == KX_TRUE)
-       {
-               m_restart = true;
-       }
-       else if (boolArg == KX_FALSE)
-       {
-               m_restart = false;
-       }
-       else
-       {
-               ; /* internal error */
-       }
+       m_restart = boolArg != 0;
        
        Py_Return;
 }
index 9baa9377f02c227e903c30637ce080a97064a535..9091a41d0549cbd7e25bcdf304a0577d86e285f2 100644 (file)
@@ -369,15 +369,7 @@ PyObject* KX_TouchSensor::PyGetTouchMaterial(PyObject* self,
                                                                                         PyObject* args, 
                                                                                         PyObject* kwds)
 {
-       int retval = 0;
-       
-       if (m_bFindMaterial) {
-               retval = KX_TRUE;
-       } else {
-               retval = KX_FALSE;
-       }
-
-       return PyInt_FromLong(retval);
+       return PyInt_FromLong(m_bFindMaterial);
 }
 
 /* 6. setTouchMaterial */
@@ -394,13 +386,7 @@ PyObject* KX_TouchSensor::PySetTouchMaterial(PyObject* self, PyObject* args, PyO
                return NULL;
        }
        
-       if (pulseArg == KX_TRUE) {
-               m_bFindMaterial = true;
-       } else if (pulseArg == KX_FALSE){
-               m_bFindMaterial = false;
-       } else {
-               ; /* internal error */
-       }
+       m_bFindMaterial = pulseArg != 0;
 
        Py_Return;
 }
index 8dbc040368b81e18bc5ef6003ce0cef7fb8d2122..268fb9cc172c06caadca69b9ea1918eca66491ac 100644 (file)
@@ -101,28 +101,66 @@ Function Keys
 
 Other Keys
 ----------
-       - ESCKEY
-       - TABKEY
-       - RETKEY
-       - SPACEKEY
-       - LINEFEEDKEY
-       - BACKSPACEKEY
-       - DELKEY
-       - SEMICOLONKEY
-       - PERIODKEY
-       - COMMAKEY
-       - QUOTEKEY
        - ACCENTGRAVEKEY
-       - MINUSKEY
-       - SLASHKEY
        - BACKSLASHKEY
+       - BACKSPACEKEY
+       - COMMAKEY
+       - DELKEY
+       - ENDKEY
        - EQUALKEY
-       - LEFTBRACKETKEY
-       - RIGHTBRACKETKEY
-       - PAUSEKEY
-       - INSERTKEY
+       - ESCKEY
        - HOMEKEY
-       - PAGEUPKEY
+       - INSERTKEY
+       - LEFTBRACKETKEY
+       - LINEFEEDKEY
+       - MINUSKEY
        - PAGEDOWNKEY
-       - ENDKEY
+       - PAGEUPKEY
+       - PAUSEKEY
+       - PERIODKEY
+       - QUOTEKEY
+       - RIGHTBRACKETKEY
+       - RETKEY
+       - SEMICOLONKEY
+       - SLASHKEY
+       - SPACEKEY
+       - TABKEY
+
+Example::
+       # Set a connected keyboard sensor to accept F1
+       import GameLogic
+       import GameKeys
+       
+       co = GameLogic.getCurrentController()
+       # 'Keyboard' is a keyboard sensor
+       sensor = co.getSensor('Keyboard')
+       sensor.setKey(GameKeys.F1KEY)
+
+Example::
+       # Do the all keys thing
+       import GameLogic
+       import GameKeys
+
+       # status: these should be added to a module somewhere
+       KX_NO_INPUTSTATUS = 0
+       KX_JUSTACTIVATED = 1
+       KX_ACTIVE = 2
+       KX_JUSTRELEASED = 3
+               
+       co = GameLogic.getCurrentController()
+       # 'Keyboard' is a keyboard sensor
+       sensor = co.getSensor('Keyboard')
+       keylist = sensor.getPressedKeys()
+       for key in keylist:
+               # key[0] == GameKeys.keycode, key[1] = status
+               if key[1] == KX_JUSTACTIVATED:
+                       if key[0] == GameKeys.WKEY:
+                               # Activate Forward!
+                       if key[0] == GameKeys.SKEY:
+                               # Activate Backward!
+                       if key[0] == GameKeys.AKEY:
+                               # Activate Left!
+                       if key[0] == GameKeys.DKEY:
+                               # Activate Right!
+               
 """
index 08f71e50f97bc7be57d0886106d494a453843f76..d4fccc7c3a04ca7371079df891e5c71f43b93316 100644 (file)
@@ -17,65 +17,108 @@ Documentation for the GameLogic Module.
                
                # To get the game object associated with this controller:
                obj = co.getOwner()
-       L{KX_GameObject} and possibly L{KX_Camera} and L{KX_Light} methods are
+       L{KX_GameObject} and L{KX_Camera} or L{KX_Light} methods are
        available depending on the type of object::
                # To get a sensor linked to this controller.
                # "sensorname" is the name of the sensor as defined in the Blender interface.
+               # +---------------------+  +--------+
+               # | Sensor "sensorname" +--+ Python +
+               # +---------------------+  +--------+
                sens = co.getSensor("sensorname")
-       L{KX_NetworkMessageSensor}, L{KX_RaySensor}, L{KX_TouchSensor}, L{SCA_KeyboardSensor}, 
-       L{SCA_MouseSensor}, L{SCA_PropertySensor} and L{SCA_RandomSensor} methods are available, 
-       depending on the type of sensor::
+       
                # To get a list of all sensors:
-               sensors = co.B{getSensors}()
+               sensors = co.getSensors()
+
+       See the sensor's reference for available methods:
+               - L{KX_NetworkMessageSensor}
+               - L{KX_RaySensor}
+               - L{KX_MouseFocusSensor}
+               - L{KX_NearSensor}
+               - L{KX_RadarSensor}
+               - L{KX_TouchSensor}
+               - L{SCA_KeyboardSensor}
+               - L{SCA_MouseSensor}
+               - L{SCA_PropertySensor} 
+               - L{SCA_RandomSensor} 
+       
+       You can also access actuators linked to the controller::
+               # To get an actuator attached to the controller:
+               #                          +--------+  +-------------------------+
+               #                          + Python +--+ Actuator "actuatorname" |
+               #                          +--------+  +-------------------------+
+               actuator = co.getActuator("actuatorname")
+               
+               # Activate an actuator
+               GameLogic.addActiveActuator(actuator, True)
+               
+       See the actuator's reference for available methods:
+               - L{BL_ActionActuator}
+               - L{KX_CameraActuator}
+               - L{KX_CDActuator}
+               - L{KX_ConstraintActuator}
+               - L{KX_GameActuator}
+               - L{KX_IpoActuator}
+               - L{KX_NetworkMessageActuator}
+               - L{KX_ObjectActuator}
+               - L{KX_SCA_AddObjectActuator}
+               - L{KX_SCA_EndObjectActuator}
+               - L{KX_SCA_ReplaceMeshActuator}
+               - L{KX_SceneActuator}
+               - L{KX_SoundActuator}
+               - L{KX_TrackToActuator}
+               - L{KX_VisibilityActuator}
+               - L{SCA_PropertyActuator}
+               - L{SCA_RandomActuator} 
+       
+       There are also methods to access the current L{KX_Scene}::
+               # Get the current scene
+               scene = GameLogic.getCurrentScene()
+               
+               # Get the current camera
+               cam = scene.active_camera
 
+       Matricies as used by the game engine are B{row major}::
+               matrix[row][col] = blah
+       L{KX_Camera} has some examples using matricies.
 
 
-Constants
-=========
-       - KX_TRUE:  True value used by some modules
-       - KX_FALSE: False value used by some modules.
+@group Constants: KX_TRUE, KX_FALSE
+@var KX_TRUE: True value used by some modules.
+@var KX_FALSE: False value used by some modules.
 
-Property Sensor
----------------
-       Tests that the property sensor is able to perform. See L{SCA_PropertySensor}
-               - KX_PROPSENSOR_EQUAL:          Activate when the property is equal to the sensor value.
-               - KX_PROPSENSOR_NOTEQUAL:       Activate when the property is not equal to the sensor value.
-               - KX_PROPSENSOR_INTERVAL:       Activate when the property is between the specified limits.
-               - KX_PROPSENSOR_CHANGED:        Activate when the property changes
-               - KX_PROPSENSOR_EXPRESSION:     Activate when the expression matches
+@group Property Sensor: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL, KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED, KX_PROPSENSOR_EXPRESSION
+@var KX_PROPSENSOR_EQUAL:              Activate when the property is equal to the sensor value.
+@var KX_PROPSENSOR_NOTEQUAL:   Activate when the property is not equal to the sensor value.
+@var KX_PROPSENSOR_INTERVAL:   Activate when the property is between the specified limits.
+@var KX_PROPSENSOR_CHANGED:    Activate when the property changes
+@var KX_PROPSENSOR_EXPRESSION: Activate when the expression matches
 
-Constraint Actuator
--------------------
-       The axis and type (location/rotation) of constraint. See L{KX_ConstraintActuator}
-               - KX_CONSTRAINTACT_LOCX
-               - KX_CONSTRAINTACT_LOCY
-               - KX_CONSTRAINTACT_LOCZ
-               - KX_CONSTRAINTACT_ROTX
-               - KX_CONSTRAINTACT_ROTY
-               - KX_CONSTRAINTACT_ROTZ
+@group Constraint Actuator: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ, KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ
+@var KX_CONSTRAINTACT_LOCX: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_LOCY: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_LOCZ: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_ROTX: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_ROTY: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_ROTZ: See L{KX_ConstraintActuator}
 
-IPO Actuator
-------------
-       IPO Types.  See L{KX_IpoActuator}
-               - KX_IPOACT_PLAY
-               - KX_IPOACT_PINGPONG
-               - KX_IPOACT_FLIPPER
-               - KX_IPOACT_LOOPSTOP
-               - KX_IPOACT_LOOPEND
+@group IPO Actuator: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
+@var KX_IPOACT_PLAY:    See L{KX_IpoActuator}
+@var KX_IPOACT_PINGPONG:        See L{KX_IpoActuator}
+@var KX_IPOACT_FLIPPER:         See L{KX_IpoActuator}
+@var KX_IPOACT_LOOPSTOP:        See L{KX_IpoActuator}
+@var KX_IPOACT_LOOPEND:         See L{KX_IpoActuator}
 
-Random Distributions
---------------------
-       See L{SCA_RandomActuator}
-               - KX_RANDOMACT_BOOL_CONST
-               - KX_RANDOMACT_BOOL_UNIFORM
-               - KX_RANDOMACT_BOOL_BERNOUILLI
-               - KX_RANDOMACT_INT_CONST
-               - KX_RANDOMACT_INT_UNIFORM
-               - KX_RANDOMACT_INT_POISSON
-               - KX_RANDOMACT_FLOAT_CONST
-               - KX_RANDOMACT_FLOAT_UNIFORM
-               - KX_RANDOMACT_FLOAT_NORMAL
-               - KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
+@group Random Distributions: KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI, KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON, KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL, KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
+@var KX_RANDOMACT_BOOL_CONST:          See L{SCA_RandomActuator}
+@var KX_RANDOMACT_BOOL_UNIFORM:                See L{SCA_RandomActuator}
+@var KX_RANDOMACT_BOOL_BERNOUILLI:             See L{SCA_RandomActuator}
+@var KX_RANDOMACT_INT_CONST:           See L{SCA_RandomActuator}
+@var KX_RANDOMACT_INT_UNIFORM:         See L{SCA_RandomActuator}
+@var KX_RANDOMACT_INT_POISSON:         See L{SCA_RandomActuator}
+@var KX_RANDOMACT_FLOAT_CONST:         See L{SCA_RandomActuator}
+@var KX_RANDOMACT_FLOAT_UNIFORM:               See L{SCA_RandomActuator}
+@var KX_RANDOMACT_FLOAT_NORMAL:                See L{SCA_RandomActuator}
+@var KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL:          See L{SCA_RandomActuator}
 
 """
 
index 1d1b7197977c62efc9592725e7d57e47f4f98826..939da3da5914031bbf7db8839259080a37d99e47 100644 (file)
@@ -94,7 +94,7 @@ class KX_Camera(KX_GameObject):
                        co = GameLogic.getCurrentController()
                        cam = co.GetOwner()
        
-                       # Test point [0.0, 0.0, 0.0]"
+                       # Test point [0.0, 0.0, 0.0]
                        if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
                                # Point is inside frustum !
                                # Do something useful !
index 2ba57dc9d7853f0312325fd934fcb7e8f0814053..4a0a7a9556d752321327b494a4e911fb32e6d7a0 100644 (file)
@@ -34,6 +34,8 @@ class KX_Scene:
                
                # Depth is negative and decreasing further from the camera
                depth = obj.position[0]*cam.world_to_camera[2][0] + obj.position[1]*cam.world_to_camera[2][1] + obj.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
+       
+       @bug: All attributes are read only at the moment.
                
        @ivar name: The scene's name
        @type name: string
index e90fb9cc2f1026e9e5bf11872e77acf956191740..2f741f7d6a2725d61f30525914b09fb8f6c1f06b 100644 (file)
@@ -6,7 +6,7 @@ class SCA_KeyboardSensor(SCA_ISensor):
        """
        A keyboard sensor detects player key presses.
        
-       See module GameKeys for keycode values.
+       See module L{GameKeys} for keycode values.
        """
        
        def getKey():
@@ -18,7 +18,7 @@ class SCA_KeyboardSensor(SCA_ISensor):
                """
                Set the key this sensor should listen for.
                
-               @type keycode: keycode from GameKeys module
+               @type keycode: keycode from L{GameKeys} module
                """
        
        def getHold1():
index 28185dabca6e971a2b4d9ebfc16d99ba12f7c918..480bd9f1d11c5331e439d226565873c71269cfb2 100644 (file)
@@ -70,10 +70,11 @@ public:
 class KX_MeshSlot
 {
 public:
-       void*                                   m_clientObj;
+       void*                           m_clientObj;
        RAS_Deformer*                   m_pDeformer;    //      __NLA
-       double*                                 m_OpenGLMatrix;
-       class RAS_MeshObject*   m_mesh;
+       double*                         m_OpenGLMatrix;
+       class RAS_MeshObject*           m_mesh;
+       
        mutable bool                    m_bVisible; // for visibility
        mutable bool                m_bObjectColor;
        mutable MT_Vector4              m_RGBAcolor;
index c048479a46e9e88da8624fbbaeb82aab4e02cb90..ff5e674150bce9ed4901101a48a1cbf671087643 100644 (file)
@@ -564,14 +564,14 @@ RAS_MeshObject::polygonSlot::polygonSlot(const MT_Vector3 &pnorm, const MT_Scala
        {
                vert = mesh->GetVertex(base.m_vtxarray, base.m_indexarray[i], poly->GetMaterial()->GetPolyMaterial());
                float z = MT_dot(pnorm, vert->getLocalXYZ()) + pval;
-               if (z > m_z)
+               if (z < m_z)
                        m_z = z;
        }
 }
 
 void RAS_MeshObject::SortPolygons(const MT_Transform &transform)
 {
-       
+       // Extract camera Z plane...
        const MT_Vector3 pnorm(transform.getBasis()[2]);
        const MT_Scalar pval = transform.getOrigin()[2];
        
@@ -593,6 +593,7 @@ void RAS_MeshObject::SortPolygons(const MT_Transform &transform)
                }
        }
        
+       // Clear current array data.
        for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it)
        {
                vector<KX_IndexArray*> *indexcache = &GetArrayOptimizer((*it)->GetPolyMaterial())->m_IndexArrayCache1;
@@ -600,8 +601,6 @@ void RAS_MeshObject::SortPolygons(const MT_Transform &transform)
                        (*iit)->clear();
        }
 
-       //ClearArrayData();
-       
        std::multiset<polygonSlot, fronttoback>::iterator sit = solidpolyset.begin();
        for (; sit != solidpolyset.end(); ++sit)
                SchedulePoly((*sit).m_poly->GetVertexIndexBase(), (*sit).m_poly->VertexCount(), (*sit).m_poly->GetMaterial()->GetPolyMaterial());
@@ -659,7 +658,7 @@ void RAS_MeshObject::SchedulePolygons(const MT_Transform &transform, int drawing
                m_bModified = false;
        } 
        
-       if (m_zsort)
+       if (m_zsort && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
        {
                SortPolygons(transform);
        }