From d855a4198d67eac8bdb7a180c0a25d747d5e8bfa Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Tue, 5 Mar 2019 18:07:29 +0100 Subject: Fixes + Optimisation to collision detection Collision is only triggered once for every Object Added options to deactivate collision and input handling to save resources --- cObjectHandler.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cObjectHandler.h') 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; }; -- cgit v1.2.3