From: sf17k Date: Mon, 15 Apr 2013 23:17:57 +0000 (-0400) Subject: made convenience functions inlineable to avoid performance hit X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=38d21f685e669429419970d4bb7e7c806592e131;p=lugaru.git made convenience functions inlineable to avoid performance hit --- diff --git a/Source/Person.cpp b/Source/Person.cpp index 33a57f3..6cee802 100644 --- a/Source/Person.cpp +++ b/Source/Person.cpp @@ -85,21 +85,6 @@ extern bool gamestarted; Person player[maxplayers]; -/* convenience functions - */ -Joint& Person::joint(int bodypart) -{ - return skeleton.joints[skeleton.jointlabels[bodypart]]; -} -XYZ& Person::jointPos(int bodypart) -{ - return joint(bodypart).position; -} -XYZ& Person::jointVel(int bodypart) -{ - return joint(bodypart).velocity; -} - /* EFFECT * * USES: diff --git a/Source/Person.h b/Source/Person.h index 754a046..7f8364e 100644 --- a/Source/Person.h +++ b/Source/Person.h @@ -326,10 +326,11 @@ public: - // convenience - Joint& joint(int); - XYZ& jointPos(int); - XYZ& jointVel(int); + // convenience functions + inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; } + inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; } + inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; } + void CheckKick(); void CatchFire(); @@ -394,4 +395,5 @@ public: const int maxplayers = 10; extern Person player[maxplayers]; + #endif diff --git a/Source/Skeleton.cpp b/Source/Skeleton.cpp index 90f8541..115b1cc 100644 --- a/Source/Skeleton.cpp +++ b/Source/Skeleton.cpp @@ -45,22 +45,6 @@ extern int whichjointendarray[26]; extern bool visibleloading; -/* convenience functions - */ -Joint& Skeleton::joint(int bodypart) -{ - return joints[jointlabels[bodypart]]; -} -XYZ& Skeleton::jointPos(int bodypart) -{ - return joint(bodypart).position; -} -XYZ& Skeleton::jointVel(int bodypart) -{ - return joint(bodypart).velocity; -} - - /* EFFECT */ void dealloc2(void* param) diff --git a/Source/Skeleton.h b/Source/Skeleton.h index 20429af..63e1ad6 100644 --- a/Source/Skeleton.h +++ b/Source/Skeleton.h @@ -221,9 +221,12 @@ public: ~Skeleton(); private: - Joint& joint(int bodypart); - XYZ& jointPos(int bodypart); - XYZ& jointVel(int bodypart); + // convenience functions + // only for Skeleton.cpp + inline Joint& joint(int bodypart) { return joints[jointlabels[bodypart]]; } + inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; } + inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; } + }; #endif