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:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-03-12 01:11:52 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2009-03-12 01:11:52 +0300
commita37cec2802d96306426f41c64f6ed69ab3680355 (patch)
treed0ad9ba1a8fb64072a6427e82b0fc4aa2a153d83 /source/gameengine/Expressions/Value.cpp
parent0ac3e7016048a7e66285b3539c6e86cf83a4cb06 (diff)
BGE patch 18368: Modulus (ie %) expression controller in BGE. Implement a cache for the expression for better performance.
Diffstat (limited to 'source/gameengine/Expressions/Value.cpp')
-rw-r--r--source/gameengine/Expressions/Value.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index d29e3961c65..ebb12636ac2 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -52,6 +52,10 @@ PyObject* cvalue_div(PyObject*v, PyObject*w)
{
return ((CValue*)v)->Calc(VALUE_DIV_OPERATOR,(CValue*)w);
}
+PyObject* cvalue_mod(PyObject*v, PyObject*w)
+{
+ return ((CValue*)v)->Calc(VALUE_MOD_OPERATOR,(CValue*)w);
+}
PyObject* cvalue_neg(PyObject*v)
{
return ((CValue*)v)->Calc(VALUE_NEG_OPERATOR,(CValue*)v);
@@ -112,7 +116,7 @@ static PyNumberMethods cvalue_as_number = {
(binaryfunc)cvalue_sub, /*nb_subtract*/
(binaryfunc)cvalue_mul, /*nb_multiply*/
(binaryfunc)cvalue_div, /*nb_divide*/
- 0,//(binaryfunc)cvalue_remainder, /*nb_remainder*/
+ (binaryfunc)cvalue_mod, /*nb_remainder*/
0,//(binaryfunc)cvalue_divmod, /*nb_divmod*/
0,//0,//0,//0,//(ternaryfunc)cvalue_pow, /*nb_power*/
(unaryfunc)cvalue_neg, /*nb_negative*/
@@ -257,6 +261,9 @@ STR_String CValue::op2str (VALUE_OPERATOR op)
STR_String opmsg;
switch (op) {
+ case VALUE_MOD_OPERATOR:
+ opmsg = " % ";
+ break;
case VALUE_ADD_OPERATOR:
opmsg = " + ";
break;