Miscellaneous Fixes:

Add Python Mapping method to CListValue
Fix Bernoulli bool distribution python method for random actuator
Fix Python IpoActuator methods setProperty and force acts local
Make data objects private
Better sort method for polygon materials - much easier to understand
This commit is contained in:
Kester Maddock 2004-06-04 03:00:13 +00:00
parent 4ff321d507
commit 44f45894c2
16 changed files with 76 additions and 61 deletions

@ -28,8 +28,6 @@ int listvalue_bufferlen(PyObject* list)
return ( ((CListValue*)list)->GetCount());
}
PyObject* listvalue_buffer_item(PyObject* list,int index)
{
if (index >= 0 && index < ((CListValue*) list)->GetCount())
@ -45,6 +43,19 @@ PyObject* listvalue_buffer_item(PyObject* list,int index)
return NULL;
}
PyObject* listvalue_mapping_subscript(PyObject* list,PyObject* pyindex)
{
if (PyString_Check(pyindex))
{
STR_String index(PyString_AsString(pyindex));
CValue *item = ((CListValue*) list)->FindValue(index);
if (item)
return (PyObject*) item;
}
Py_Error(PyExc_IndexError, "Python ListIndex out of range");
Py_Return;
}
/* just slice it into a python list... */
@ -157,7 +168,7 @@ static PySequenceMethods listvalue_as_sequence = {
/* Is this one used ? */
static PyMappingMethods instance_as_mapping = {
(inquiry)listvalue_bufferlen, /*mp_length*/
0,//(binaryfunc)instance_subscript, /*mp_subscript*/
(binaryfunc)listvalue_mapping_subscript, /*mp_subscript*/
0,//(objobjargproc)instance_ass_subscript, /*mp_ass_subscript*/
};

@ -39,6 +39,7 @@
class SCA_ILogicBrick : public CValue
{
Py_Header;
protected:
SCA_IObject* m_gameobj;
int m_Execute_Priority;
int m_Execute_Ueber_Priority;
@ -48,7 +49,6 @@ class SCA_ILogicBrick : public CValue
STR_String m_text;
STR_String m_name;
//unsigned long m_drawcolor;
protected:
void RegisterEvent(CValue* eventval);
void RemoveEvent();
CValue* GetEvent();

@ -495,7 +495,7 @@ PyObject* SCA_RandomActuator::PySetBoolBernouilli(PyObject* self,
return NULL;
}
m_distribution = KX_RANDOMACT_BOOL_CONST;
m_distribution = KX_RANDOMACT_BOOL_BERNOUILLI;
m_parameter1 = paraArg;
enforceConstraints();
Py_Return;

@ -48,10 +48,8 @@
class KX_CameraActuator : public SCA_IActuator
{
private :
Py_Header;
private :
/** Object that will be tracked. */
const CValue *m_ob;

@ -41,7 +41,7 @@
class KX_ConstraintActuator : public SCA_IActuator
{
Py_Header;
protected:
// Damp time (int),
int m_dampTime;
// min (float),

@ -41,6 +41,7 @@
class KX_GameActuator : public SCA_IActuator
{
Py_Header;
protected:
int m_mode;
bool m_restart;
STR_String m_filename;

@ -428,6 +428,10 @@ PyMethodDef KX_IpoActuator::Methods[] = {
METH_VARARGS, SetType_doc},
{"getType", (PyCFunction) KX_IpoActuator::sPyGetType,
METH_VARARGS, GetType_doc},
{"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal,
METH_VARARGS, SetForceIpoActsLocal_doc},
{"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal,
METH_VARARGS, GetForceIpoActsLocal_doc},
{NULL,NULL} //Sentinel
};
@ -494,6 +498,8 @@ PyObject* KX_IpoActuator::PySetProperty(PyObject* self,
return NULL;
}
m_propname = propertyName;
Py_Return;
}

@ -40,7 +40,7 @@
class KX_IpoActuator : public SCA_IActuator
{
Py_Header;
protected:
bool m_bNegativeEvent;
/** Begin frame of the ipo. */

@ -77,6 +77,29 @@ KX_RadarSensor::~KX_RadarSensor()
}
CValue* KX_RadarSensor::GetReplica()
{
KX_RadarSensor* replica = new KX_RadarSensor(*this);
replica->m_colliders = new CListValue();
replica->m_bCollision = false;
replica->m_bTriggered= false;
replica->m_hitObject = NULL;
replica->m_bLastTriggered = false;
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
replica->m_client_info = new KX_ClientObjectInfo(m_client_info->m_clientobject, KX_ClientObjectInfo::RADAR);
replica->m_sumoObj = new SM_Object(DT_NewCone(m_coneradius, m_coneheight),NULL,NULL,NULL);
replica->m_sumoObj->setMargin(m_Margin);
replica->m_sumoObj->setClientObject(replica->m_client_info);
replica->SynchronizeTransform();
return replica;
}
/**
* Transforms the collision object. A cone is not correctly centered
* for usage. */

@ -77,6 +77,7 @@ public:
KX_RadarSensor();
virtual ~KX_RadarSensor();
virtual void SynchronizeTransform();
virtual CValue* GetReplica();
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */

@ -57,7 +57,8 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname,
m_transparant(transparant),
m_zsort(zsort),
m_lightlayer(lightlayer),
m_bIsTriangle(bIsTriangle)
m_bIsTriangle(bIsTriangle),
m_polymatid(m_newpolymatid++)
{
m_shininess = 35.0;
m_specular = MT_Vector3(0.5,0.5,0.5);
@ -84,48 +85,10 @@ bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const
bool RAS_IPolyMaterial::Less(const RAS_IPolyMaterial& rhs) const
{
/**
* @warning STL requires lhs.Less(rhs) == rhs.Less(lhs) implies lhs.Equals(rhs).
* This function *must* return different values for lhs.Less(rhs) and rhs.Less(lhs) if
* !lhs.Equals(rhs) !!
*/
if (m_materialname.hash() < rhs.m_materialname.hash())
return true;
if (m_materialname.hash() > rhs.m_materialname.hash() ||
m_texturename.hash() > rhs.m_texturename.hash())
if (Equals(rhs))
return false;
if (m_texturename.hash() < rhs.m_texturename.hash() ||
m_lightlayer < rhs.m_lightlayer)
return true;
if (m_lightlayer > rhs.m_lightlayer ||
m_bIsTriangle > rhs.m_bIsTriangle)
return false;
if (m_bIsTriangle < rhs.m_bIsTriangle ||
m_drawingmode < rhs.m_drawingmode)
return true;
if (m_drawingmode > rhs.m_drawingmode ||
m_transparant > !rhs.m_transparant)
return false;
if (m_transparant < rhs.m_transparant ||
m_tileyrep < rhs.m_tileyrep)
return true;
if (m_tileyrep > rhs.m_tileyrep ||
m_tilexrep > rhs.m_tilexrep)
return false;
if (m_tilexrep < rhs.m_tilexrep ||
m_tile < rhs.m_tile)
return true;
return !(m_tile > rhs.m_tile ||
m_zsort > rhs.m_zsort);
return m_polymatid < rhs.m_polymatid;
}
int RAS_IPolyMaterial::GetLightLayer() const
@ -167,3 +130,5 @@ const STR_String& RAS_IPolyMaterial::GetTextureName() const
{
return m_texturename;
}
unsigned int RAS_IPolyMaterial::m_newpolymatid = 0;

@ -60,6 +60,10 @@ protected:
int m_lightlayer;
bool m_bIsTriangle;
unsigned int m_polymatid;
static unsigned int m_newpolymatid;
public:
MT_Vector3 m_diffuse;

@ -299,13 +299,21 @@ public:
float frustfar,
bool perspective = true
)=0;
/**
* Sets the specular colour component of the lighting equation.
*/
virtual void SetSpecularity(float specX,
float specY,
float specZ,
float specval)=0;
/**
* Sets the specular exponent component of the lighting equation.
*/
virtual void SetShinyness(float shiny)=0;
/**
* Sets the diffuse colour component of the lighting equation.
*/
virtual void SetDiffuse(float difX,
float difY,
float difZ,

@ -257,9 +257,9 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans,
if (m_meshSlots.begin()== m_meshSlots.end())
return;
rendertools->SetViewMat(cameratrans);
//rendertools->SetViewMat(cameratrans);
rasty->SetMaterial(*m_material);
//rasty->SetMaterial(*m_material);
if (m_meshSlots.size() >0)
{

@ -686,7 +686,7 @@ void RAS_OpenGLRasterizer::IndexPrimitives_Ex(const vecVertexArray & vertexarray
numindices = indexarray.size();
if (!numindices)
break;
continue;
int vindex=0;
switch (mode)
@ -777,7 +777,7 @@ void RAS_OpenGLRasterizer::IndexPrimitives_Ex(const vecVertexArray & vertexarray
mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
mv4 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
mv4 = MT_Point3(vertexarray[(indexarray[vindex+3])].getLocalXYZ());
fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized();

@ -183,8 +183,6 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays
glColor3d(0,0,0);
}
// use glDrawElements to draw each vertexarray
static bool doWarning = true;
for (vt=0;vt<vertexarrays.size();vt++)
{
vertexarray = &((*vertexarrays[vt]) [0]);
@ -193,7 +191,7 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays
int numverts = vertexarrays[vt]->size();
if (!numindices)
break;
continue;
glVertexPointer(3,GL_FLOAT,vtxstride,vertexarray->getLocalXYZ());
glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1());