aboutsummaryrefslogtreecommitdiff
path: root/cObjectHandler.h
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-03-05 18:07:29 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-03-05 18:07:29 +0100
commitd855a4198d67eac8bdb7a180c0a25d747d5e8bfa (patch)
treed34da81fdb80dc177be12a985d0704d5471e470f /cObjectHandler.h
parentda1a27f74e13d6ab94696fd8dc5d20526c6973c6 (diff)
downloadtermgl-d855a4198d67eac8bdb7a180c0a25d747d5e8bfa.tar.gz
Fixes + Optimisation to collision detection
Collision is only triggered once for every Object Added options to deactivate collision and input handling to save resources
Diffstat (limited to 'cObjectHandler.h')
-rw-r--r--cObjectHandler.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/cObjectHandler.h b/cObjectHandler.h
index 1e872b3..4a0306b 100644
--- a/cObjectHandler.h
+++ b/cObjectHandler.h
@@ -20,16 +20,19 @@ struct sCollision
};
/**
-* Manages cObject and cWiremesh and writes them to a cRender framebuffer.
+* Manages cObject and cWiremesh and writes them to a cRender framebuffer (Also works on cObject, since it inherits from cRender!).
* forwards input events to corresponding cObject.
+* Runs collision checking for every move operation. This is very expensive, so deactivate if not needed (eg. for background animations etc)!
*/
class cObjectHandler
{
public:
/**
* *_render: pointer to instance of cRender all objects will be written to
+ * _enableCollision: activate collision checking globally. CAUTION: Collision requires InputMapping. If InputMapping is disabled, Collision will NOT WORK!
+ * _enableInputMapping: activate Input mapping for mouse and keyboard events
*/
- explicit cObjectHandler(cRender *_render);
+ explicit cObjectHandler(cRender *_render, bool _enableInputMapping = true, bool _enableCollision = true);
/**
* Adds _object to managed objects vector
@@ -97,6 +100,9 @@ public:
private:
+ /**
+ * This function is very expensive! Only use when needed!
+ */
sCollision checkCollision(sPos _pos, sPos _size);
void buildHitmap();
@@ -107,4 +113,6 @@ private:
cRender *render;
unsigned long int iActiveObject;
sPos cameraPosition;
+ bool enableCollision;
+ bool enableInputMapping;
};