annotate engine/core/view/renderers/instancerenderer.cpp @ 572:da381ecca97d

* This is a better solution as in commit 3374. Now only visible instances be added to the RenderList. fixes[ticket:471]
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 30 Jun 2010 04:57:35 +0000
parents edc9efe969c2
children 716fbe02140a
rev   line source
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
6 * FIFE is free software; you can redistribute it and/or *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
7 * modify it under the terms of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
8 * License as published by the Free Software Foundation; either *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
9 * version 2.1 of the License, or (at your option) any later version. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
11 * This library is distributed in the hope that it will be useful, *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
14 * Lesser General Public License for more details. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
16 * You should have received a copy of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
17 * License along with this library; if not, write to the *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 39
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 // Standard C++ library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 // 3rd party library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 // FIFE includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 // These includes are split up in two parts, separated by one empty line
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 // First block: files included from the FIFE root src directory
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 // Second block: files included from the same folder
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 #include "video/renderbackend.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 #include "video/image.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 #include "video/sdl/sdlimage.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 #include "video/imagepool.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 #include "video/animation.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 #include "video/animationpool.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 #include "util/math/fife_math.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 #include "util/log/logger.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 #include "model/metamodel/grids/cellgrid.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 #include "model/metamodel/action.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40 #include "model/structures/instance.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 #include "model/structures/layer.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 #include "model/structures/location.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 #include "view/camera.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 #include "view/visual.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 #include "instancerenderer.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
48 namespace {
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
49 unsigned int scale(unsigned int val, double factor) {
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
50 return static_cast<unsigned int>(ceil(static_cast<double>(val) * factor));
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
51 }
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
52 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 namespace FIFE {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 static Logger _log(LM_VIEWVIEW);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
57 InstanceRenderer::OutlineInfo::OutlineInfo():
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
58 r(0),
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
59 g(0),
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
60 b(0),
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
61 width(1),
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
62 dirty(false),
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
63 outline(NULL),
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 curimg(NULL) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 InstanceRenderer::ColoringInfo::ColoringInfo():
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
67 r(0),
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
68 g(0),
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
69 b(0),
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
70 dirty(false),
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 overlay(NULL),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 curimg(NULL) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
74
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
75 InstanceRenderer::OutlineInfo::~OutlineInfo() {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 delete outline;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
78
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 InstanceRenderer::ColoringInfo::~ColoringInfo() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 delete overlay;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
82
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 InstanceRenderer* InstanceRenderer::getInstance(IRendererContainer* cnt) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 return dynamic_cast<InstanceRenderer*>(cnt->getRenderer("InstanceRenderer"));
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
86
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 InstanceRenderer::InstanceRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 RendererBase(renderbackend, position),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 m_imagepool(imagepool),
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
90 m_animationpool(animpool) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 setEnabled(true);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94 InstanceRenderer::InstanceRenderer(const InstanceRenderer& old):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95 RendererBase(old),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96 m_imagepool(old.m_imagepool),
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
97 m_animationpool(old.m_animationpool) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 setEnabled(true);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 RendererBase* InstanceRenderer::clone() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 return new InstanceRenderer(*this);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 InstanceRenderer::~InstanceRenderer() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
107
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 356
diff changeset
108 void InstanceRenderer::render(Camera* cam, Layer* layer, RenderList& instances) {
135
52d4a149389d - applied layer visibility patch from abeyer (ticket #335)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 95
diff changeset
109 // patch #335 by abeyer
52d4a149389d - applied layer visibility patch from abeyer (ticket #335)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 95
diff changeset
110 if (!layer->areInstancesVisible()) {
52d4a149389d - applied layer visibility patch from abeyer (ticket #335)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 95
diff changeset
111 FL_DBG(_log, "Layer instances hidden");
52d4a149389d - applied layer visibility patch from abeyer (ticket #335)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 95
diff changeset
112 return;
52d4a149389d - applied layer visibility patch from abeyer (ticket #335)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 95
diff changeset
113 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
114
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 FL_DBG(_log, "Iterating layer...");
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 CellGrid* cg = layer->getCellGrid();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 if (!cg) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 FL_WARN(_log, "No cellgrid assigned to layer, cannot draw instances");
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 return;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
121
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
122 const bool any_effects = !(m_instance_outlines.empty() && m_instance_colorings.empty());
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 356
diff changeset
124 RenderList::iterator instance_it = instances.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 for (;instance_it != instances.end(); ++instance_it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 FL_DBG(_log, "Iterating instances...");
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 356
diff changeset
127 Instance* instance = (*instance_it)->instance;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 InstanceVisual* visual = instance->getVisual<InstanceVisual>();
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 356
diff changeset
129 RenderItem& vc = **instance_it;
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
130 unsigned char trans = visual->getTransparency();
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
131
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
132 /**
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
133 * the instance transparency value take precedence. If it's 0 use the layer trans
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
134 *
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
135 * \todo Instances cannot be completely opaque when their layer's transparency is non zero.
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
136 */
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
137 if (trans == 0) {
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
138 unsigned char layer_trans = layer->getLayerTransparency();
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
139 trans = layer_trans;
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
140 }
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
141
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 FL_DBG(_log, LMsg("Instance layer coordinates = ") << instance->getLocationRef().getLayerCoordinates());
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
143
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
144 if (any_effects) {
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
145 InstanceToOutlines_t::iterator outline_it = m_instance_outlines.find(instance);
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
146 if (outline_it != m_instance_outlines.end()) {
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
147 bindOutline(outline_it->second, vc, cam)->render(vc.dimensions, 255-trans);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
149
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
150 InstanceToColoring_t::iterator coloring_it = m_instance_colorings.find(instance);
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
151 if (coloring_it != m_instance_colorings.end()) {
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
152 bindColoring(coloring_it->second, vc, cam)->render(vc.dimensions, 255-trans);
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
153 continue; // Skip normal rendering after drawing overlay
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
154 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
156
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
157 vc.image->render(vc.dimensions, 255-trans);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
160
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 356
diff changeset
161 Image* InstanceRenderer::bindOutline(OutlineInfo& info, RenderItem& vc, Camera* cam) {
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
162 if (!info.dirty && info.curimg == vc.image) {
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
163 // optimization for outline that has not changed
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 return info.outline;
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
165 } else {
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
166 info.curimg = vc.image;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
168
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 if (info.outline) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 delete info.outline; // delete old mask
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 info.outline = NULL;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 SDL_Surface* surface = vc.image->getSurface();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 SDL_Surface* outline_surface = SDL_ConvertSurface(surface, surface->format, surface->flags);
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
175
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 // needs to use SDLImage here, since GlImage does not support drawing primitives atm
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 SDLImage* img = new SDLImage(outline_surface);
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
178
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 // TODO: optimize...
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 uint8_t r, g, b, a = 0;
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
181
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 // vertical sweep
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 for (unsigned int x = 0; x < img->getWidth(); x ++) {
39
4e68022ed545 fix some pixels wrongly highlighted in outlines
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
184 uint8_t prev_a = 0;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 for (unsigned int y = 0; y < img->getHeight(); y ++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 vc.image->getPixelRGBA(x, y, &r, &g, &b, &a);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 if ((a == 0 || prev_a == 0) && (a != prev_a)) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 if (a < prev_a) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 for (unsigned int yy = y; yy < y + info.width; yy++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 img->putPixel(x, yy, info.r, info.g, info.b);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 } else {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 for (unsigned int yy = y - info.width; yy < y; yy++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 img->putPixel(x, yy, info.r, info.g, info.b);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 prev_a = a;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 // horizontal sweep
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 for (unsigned int y = 0; y < img->getHeight(); y ++) {
39
4e68022ed545 fix some pixels wrongly highlighted in outlines
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
203 uint8_t prev_a = 0;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 for (unsigned int x = 0; x < img->getWidth(); x ++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 vc.image->getPixelRGBA(x, y, &r, &g, &b, &a);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 if ((a == 0 || prev_a == 0) && (a != prev_a)) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 if (a < prev_a) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 for (unsigned int xx = x; xx < x + info.width; xx++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 img->putPixel(xx, y, info.r, info.g, info.b);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211 } else {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 for (unsigned int xx = x - info.width; xx < x; xx++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 img->putPixel(xx, y, info.r, info.g, info.b);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 prev_a = a;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
220
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 // In case of OpenGL backend, SDLImage needs to be converted
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222 info.outline = m_renderbackend->createImage(img->detachSurface());
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 delete img;
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
224
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
225 if (info.outline) {
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
226 // mark outline as not dirty since we created it here
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
227 info.dirty = false;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
228 }
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
229
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 return info.outline;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 356
diff changeset
233 Image* InstanceRenderer::bindColoring(ColoringInfo& info, RenderItem& vc, Camera* cam) {
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
234 if (!info.dirty && info.curimg == vc.image) {
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
235 // optimization for coloring overlay that has not changed
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 return info.overlay;
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
237 }
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
238 else {
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
239 info.curimg = vc.image;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 }
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
241
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 if (info.overlay) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243 delete info.overlay; // delete old mask
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244 info.overlay = NULL;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
245 }
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
246
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 SDL_Surface* surface = vc.image->getSurface();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248 SDL_Surface* overlay_surface = SDL_ConvertSurface(surface, surface->format, surface->flags);
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
249
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 // needs to use SDLImage here, since GlImage does not support drawing primitives atm
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 SDLImage* img = new SDLImage(overlay_surface);
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
252
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 uint8_t r, g, b, a = 0;
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
254
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 for (unsigned int x = 0; x < img->getWidth(); x ++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 for (unsigned int y = 0; y < img->getHeight(); y ++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 vc.image->getPixelRGBA(x, y, &r, &g, &b, &a);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 if (a > 0) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 img->putPixel(x, y, (r + info.r) >> 1, (g + info.g) >> 1, (b + info.b) >> 1);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
263
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 // In case of OpenGL backend, SDLImage needs to be converted
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 info.overlay = m_renderbackend->createImage(img->detachSurface());
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 delete img;
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
267
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
268 if (info.overlay) {
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
269 // mark overlay coloring as not dirty since we created it here
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
270 info.dirty = false;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
271 }
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
272
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 return info.overlay;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 void InstanceRenderer::addOutlined(Instance* instance, int r, int g, int b, int width) {
564
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
277 OutlineInfo newinfo;
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
278 newinfo.r = r;
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
279 newinfo.g = g;
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
280 newinfo.b = b;
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
281 newinfo.width = width;
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
282 newinfo.dirty = true;
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
283
564
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
284 // attempts to insert the element into the outline map
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
285 // will return false in the second value of the pair if the instance already exists
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
286 // in the map and the first value of the pair will then be an iterator to the
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
287 // existing data for the instance
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
288 std::pair<InstanceToOutlines_t::iterator, bool> insertiter = m_instance_outlines.insert(std::make_pair(instance, newinfo));
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
289
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
290 if (insertiter.second == false) {
564
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
291 // the insertion did not happen because the instance
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
292 // already exists in the map so lets just update its outline info
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
293 OutlineInfo& info = insertiter.first->second;
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
294
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
295 if (info.r != r || info.g != g || info.b != b || info.width != width) {
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
296 // only update the outline info if its changed since the last call
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
297 // flag the outline info as dirty so it will get processed during rendering
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
298 info.r = r;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
299 info.b = b;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
300 info.g = g;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
301 info.width = width;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
302 info.dirty = true;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
303 }
564
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
304 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
305 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
306
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
307 void InstanceRenderer::addColored(Instance* instance, int r, int g, int b) {
564
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
308 ColoringInfo newinfo;
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
309 newinfo.r = r;
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
310 newinfo.g = g;
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
311 newinfo.b = b;
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
312 newinfo.dirty = true;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
313
564
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
314 // attempts to insert the element into the coloring map
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
315 // will return false in the second value of the pair if the instance already exists
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
316 // in the map and the first value of the pair will then be an iterator to the
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
317 // existing data for the instance
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
318 std::pair<InstanceToColoring_t::iterator, bool> insertiter = m_instance_colorings.insert(std::make_pair(instance, newinfo));
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
319
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
320 if (insertiter.second == false) {
564
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
321 // the insertion did not happen because the instance
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
322 // already exists in the map so lets just update its coloring info
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
323 ColoringInfo& info = insertiter.first->second;
571
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
324
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
325 if (info.r != r || info.g != g || info.b != b) {
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
326 // only update the coloring info if its changed since the last call
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
327 // flag the coloring info as dirty so it will get processed during rendering
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
328 info.r = r;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
329 info.b = b;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
330 info.g = g;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
331 info.dirty = true;
edc9efe969c2 This commit should fix the coloring overlay bug exposed by the commit in revision 3386. The InstanceRenderer was caching the overlays based on whether the current image had changed. The fix takes into account the current image as well as the overlay color to decide whether or not the overlay needs to be reproduced.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 564
diff changeset
332 }
564
7d88eddd2ec7 Modified the addColored and addOutlined methods in the InstanceRenderer class to fix a memory leak. The new code attempts to insert the information in the proper map and if it already exists it will explicitly update the reference to the existing information. The new code no longer relies on the bracket operator of the std::map which was implicitly calling the equals operator of the ColoringInfo and OutlineInfo and causing the memory leak. fixes[ticket:472]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 553
diff changeset
333 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
335
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 void InstanceRenderer::removeOutlined(Instance* instance) {
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
337 m_instance_outlines.erase(instance);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
338 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
339
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
340 void InstanceRenderer::removeColored(Instance* instance) {
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
341 m_instance_colorings.erase(instance);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
342 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
343
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
344 void InstanceRenderer::removeAllOutlines() {
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
345 m_instance_outlines.clear();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
347
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
348 void InstanceRenderer::removeAllColored() {
95
0b6998fde366 speedup instance renderer; now instances can change their layer, old optimisation made wrong asumption... (fix by yonibear)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
349 m_instance_colorings.clear();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
350 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
351
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
352 void InstanceRenderer::reset() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
353 removeAllOutlines();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
354 removeAllColored();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
355 }
356
ab41334e8a57 Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 135
diff changeset
356
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
357 }