Skip to content

Commit

Permalink
UPBGE: Remove useless code from Expression/ part.
Browse files Browse the repository at this point in the history
A lot of functions from the Expression/ part were not used and wrapped into other unused
functions.
The most sensible part is the COperator2Epr m_cached_calculate value. This value was
allowing to update the result only when the expression used were modified, but the function
SetModified() which set the expression modified was never called.
  • Loading branch information
panzergame committed Jan 3, 2017
1 parent 6e7bb11 commit 9602bf1
Show file tree
Hide file tree
Showing 29 changed files with 27 additions and 1,066 deletions.
1 change: 0 additions & 1 deletion source/gameengine/Expressions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ set(SRC
EXP_Python.h
EXP_StringValue.h
EXP_Value.h
EXP_VoidValue.h
EXP_ListWrapper.h
)

Expand Down
6 changes: 1 addition & 5 deletions source/gameengine/Expressions/EXP_BoolValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@

class CBoolValue : public CPropValue
{

//PLUGIN_DECLARE_SERIAL(CBoolValue,CValue)

public:
static const std::string sTrueString;
static const std::string sFalseString;

CBoolValue();
CBoolValue(bool inBool);
CBoolValue(bool innie, const std::string& name, AllocationTYPE alloctype = CValue::HEAPVALUE);
CBoolValue(bool innie, const std::string& name);

virtual const std::string GetText();
virtual double GetNumber();
Expand All @@ -48,7 +45,6 @@ class CBoolValue : public CPropValue
virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);

void Configure(CValue* menuvalue);
virtual CValue* GetReplica();
#ifdef WITH_PYTHON
virtual PyObject* ConvertValueToPython();
Expand Down
9 changes: 0 additions & 9 deletions source/gameengine/Expressions/EXP_ConstExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,8 @@

class CConstExpr : public CExpression
{
//PLUGIN_DECLARE_SERIAL_EXPRESSION (CConstExpr,CExpression)
public:
virtual bool MergeExpression(CExpression* otherexpr);

void BroadcastOperators(VALUE_OPERATOR op);

virtual unsigned char GetExpressionID();
CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
//bool IsInside(float x,float y,float z,bool bBorderInclude=true);
bool NeedsRecalculated();
void ClearModified();
virtual double GetNumber();
virtual CValue* Calculate();
CConstExpr(CValue* constval);
Expand Down
3 changes: 0 additions & 3 deletions source/gameengine/Expressions/EXP_EmptyValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ class CListValue;

class CEmptyValue : public CPropValue
{
//PLUGIN_DECLARE_SERIAL (CEmptyValue,CValue)
public:
CEmptyValue();
virtual ~CEmptyValue();

virtual const std::string GetText();
virtual double GetNumber();
virtual int GetValueType();
CListValue* GetPolySoup();
virtual double* GetVector3(bool bGetTransformedVec=false);
bool IsInside(CValue* testpoint,bool bBorderInclude=true);
CValue * Calc(VALUE_OPERATOR op, CValue *val);
CValue * CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
Expand Down
79 changes: 0 additions & 79 deletions source/gameengine/Expressions/EXP_Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,70 +21,6 @@

#include "EXP_Value.h"

//extern int gRefCountExpr; // only for debugging purposes (detect mem.leaks)


#define PLUGIN_DECLARE_SERIAL_EXPRESSION(class_name, base_class_name) \
public: \
virtual base_class_name * Copy() { \
return new class_name; \
} \
virtual bool EdSerialize(CompressorArchive& arch, \
class CFactoryManager* facmgr, \
bool bIsStoring); \
virtual bool EdIdSerialize(CompressorArchive& arch, \
class CFactoryManager* facmgr, \
bool bIsStoring) \
{ \
if (bIsStoring) \
{ \
unsigned char exprID = GetExpressionID(); \
arch << exprID; \
} \
return true; \
} \



class CExpression;


// for undo/redo system the deletion in the expressiontree can be restored by replacing broken links 'inplace'
class CBrokenLinkInfo
{
public:
CBrokenLinkInfo(CExpression** pmemexpr,CExpression* expr)
:m_pmemExpr(pmemexpr),
m_pExpr(expr)
{
BLI_assert(pmemexpr);
m_bRestored=false;
};

virtual ~CBrokenLinkInfo();
void RestoreLink();
void BreakLink();


// members vars
private:
CExpression** m_pmemExpr;
CExpression* m_pExpr;
bool m_bRestored;


#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:CBrokenLinkInfo")
#endif
};








class CExpression
{
public:
Expand All @@ -101,32 +37,17 @@ class CExpression
protected:
virtual ~CExpression() = 0; //pure virtual
public:
virtual bool MergeExpression(CExpression* otherexpr) = 0;
CExpression();


virtual CValue* Calculate() = 0; //pure virtual
virtual unsigned char GetExpressionID() = 0;
//virtual bool IsInside(float x,float y,float z,bool bBorderInclude=true) = 0; //pure virtual
virtual bool NeedsRecalculated() = 0; // another pure one
virtual CExpression * CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks) =0; // another pure one
virtual void ClearModified() = 0; // another pure one
//virtual CExpression * Copy() =0;
virtual void BroadcastOperators(VALUE_OPERATOR op) =0;

virtual CExpression * AddRef() { // please leave multiline, for debugger !!!

#ifdef DEBUG
//gRefCountExpr++;
BLI_assert(m_refcount < 255);
#endif
m_refcount++;
return this;
};
virtual CExpression* Release(CExpression* complicatedtrick=NULL) {
#ifdef DEBUG
//gRefCountExpr--;
#endif
if (--m_refcount < 1)
{
delete this;
Expand Down
4 changes: 1 addition & 3 deletions source/gameengine/Expressions/EXP_FloatValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@

class CFloatValue : public CPropValue
{
//PLUGIN_DECLARE_SERIAL (CFloatValue,CValue)
public:
CFloatValue();
CFloatValue(float fl);
CFloatValue(float fl,const std::string& name,AllocationTYPE alloctype=CValue::HEAPVALUE);
CFloatValue(float fl,const std::string& name);

virtual const std::string GetText();

void Configure(CValue* menuvalue);
virtual double GetNumber();
virtual int GetValueType();
virtual void SetValue(CValue* newval);
Expand Down
6 changes: 0 additions & 6 deletions source/gameengine/Expressions/EXP_IdentifierExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ class CIdentifierExpr : public CExpression
virtual ~CIdentifierExpr();

virtual CValue* Calculate();
virtual bool MergeExpression(CExpression* otherexpr);
virtual unsigned char GetExpressionID();
virtual bool NeedsRecalculated();
virtual CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
virtual void ClearModified();
virtual void BroadcastOperators(VALUE_OPERATOR op);


#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIdentifierExpr")
Expand Down
12 changes: 0 additions & 12 deletions source/gameengine/Expressions/EXP_IfExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,16 @@

class CIfExpr : public CExpression
{
//PLUGIN_DECLARE_SERIAL_EXPRESSION (CIfExpr,CExpression)

private:
CExpression *m_guard, *m_e1, *m_e2;

public:
virtual bool MergeExpression(CExpression* otherexpr);
CIfExpr(CExpression *guard, CExpression *e1, CExpression *e2);
CIfExpr();

virtual unsigned char GetExpressionID();
virtual ~CIfExpr();
virtual CValue* Calculate();

virtual bool IsInside(float x,float y,float z,bool bBorderInclude=true);
virtual bool NeedsRecalculated();


virtual CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
virtual void ClearModified();
virtual void BroadcastOperators(VALUE_OPERATOR op);


#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIfExpr")
Expand Down
8 changes: 1 addition & 7 deletions source/gameengine/Expressions/EXP_IntValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ typedef long long cInt;

class CIntValue : public CPropValue
{
//PLUGIN_DECLARE_SERIAL (CIntValue,CValue)

public:
virtual const std::string GetText();
virtual double GetNumber();
Expand All @@ -36,9 +34,7 @@ class CIntValue : public CPropValue
cInt GetInt();
CIntValue();
CIntValue(cInt innie);
CIntValue(cInt innie,
const std::string& name,
AllocationTYPE alloctype=CValue::HEAPVALUE);
CIntValue(cInt innie, const std::string& name);

virtual CValue* Calc(VALUE_OPERATOR op,
CValue *val);
Expand All @@ -49,8 +45,6 @@ class CIntValue : public CPropValue

virtual void SetValue(CValue* newval);

void Configure(CValue* menuvalue);
void AddConfigurationData(CValue* menuvalue);
virtual CValue* GetReplica();

#ifdef WITH_PYTHON
Expand Down
4 changes: 0 additions & 4 deletions source/gameengine/Expressions/EXP_ListValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class CListValue : public CPropValue
CListValue();
virtual ~CListValue();

void AddConfigurationData(CValue *menuvalue);
void Configure(CValue *menuvalue);
void Add(CValue *value);
void Insert(unsigned int i, CValue *value);

Expand Down Expand Up @@ -77,8 +75,6 @@ class CListValue : public CPropValue
CValue *FindValue(const std::string& name);

void ReleaseAndRemoveAll();
virtual void SetModified(bool bModified);
virtual inline bool IsModified();
void Remove(int i);
void Resize(int num);
void SetValue(int i, CValue *val);
Expand Down
14 changes: 0 additions & 14 deletions source/gameengine/Expressions/EXP_Operator1Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,8 @@

class COperator1Expr : public CExpression
{
//PLUGIN_DECLARE_SERIAL_EXPRESSION (COperator1Expr,CExpression)



public:
virtual bool MergeExpression(CExpression* otherexpr);
virtual void BroadcastOperators(VALUE_OPERATOR op);

virtual unsigned char GetExpressionID() { return COPERATOR1EXPRESSIONID; }
CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
//virtual bool IsInside(float x,float y,float z,bool bBorderInclude = true);
virtual bool NeedsRecalculated();
void ClearModified() {
if (m_lhs)
m_lhs->ClearModified();
}
virtual CValue* Calculate();
COperator1Expr(VALUE_OPERATOR op, CExpression *lhs);
COperator1Expr();
Expand Down
18 changes: 1 addition & 17 deletions source/gameengine/Expressions/EXP_Operator2Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,8 @@

class COperator2Expr : public CExpression
{
//PLUGIN_DECLARE_SERIAL_EXPRESSION (COperator2Expr,CExpression)

public:
virtual bool MergeExpression(CExpression* otherexpr);
virtual unsigned char GetExpressionID() { return COPERATOR2EXPRESSIONID; }
virtual void BroadcastOperators(VALUE_OPERATOR op);
CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
//virtual bool IsInside(float x,float y,float z,bool bBorderInclude=true);
//virtual bool IsLeftInside(float x,float y,float z,bool bBorderInclude);
//virtual bool IsRightInside(float x,float y,float z,bool bBorderInclude);
bool NeedsRecalculated();
void ClearModified() {
if (m_lhs)
m_lhs->ClearModified();
if (m_rhs)
m_rhs->ClearModified();
}
virtual CValue* Calculate();
COperator2Expr(VALUE_OPERATOR op, CExpression *lhs, CExpression *rhs);
COperator2Expr();
Expand All @@ -51,8 +36,7 @@ class COperator2Expr : public CExpression
protected:
CExpression * m_rhs;
CExpression * m_lhs;
CValue* m_cached_calculate; // cached result


private:
VALUE_OPERATOR m_op;

Expand Down
7 changes: 2 additions & 5 deletions source/gameengine/Expressions/EXP_StringValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@

class CStringValue : public CPropValue
{


//PLUGIN_DECLARE_SERIAL(CStringValue,CValue)
public:
/// Construction / destruction
CStringValue();
CStringValue(const std::string& txt, const std::string& name, AllocationTYPE alloctype = CValue::HEAPVALUE);
CStringValue(const std::string& txt, const std::string& name);

virtual ~CStringValue() {}
/// CValue implementation
Expand All @@ -40,7 +37,7 @@ class CStringValue : public CPropValue

virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
virtual void SetValue(CValue* newval) { m_strString = newval->GetText(); SetModified(true); }
virtual void SetValue(CValue* newval) { m_strString = newval->GetText(); }
virtual CValue* GetReplica();
#ifdef WITH_PYTHON
virtual PyObject* ConvertValueToPython() {
Expand Down
Loading

0 comments on commit 9602bf1

Please sign in to comment.