Mercurial > fife-parpg
comparison engine/core/view/renderers/instancerenderer.cpp @ 573:716fbe02140a
* Moved the layer visibility and transparency, from instancerenderer.cpp to layercache.cpp and improved it.
Note: Now you can set a instance completely opaque, when their layer is fully transparent or reverse. If both have a transparent value then the result from layer-instance is used.
author | helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 02 Jul 2010 05:49:34 +0000 |
parents | da381ecca97d |
children | d1df6cf5ff23 |
comparison
equal
deleted
inserted
replaced
572:da381ecca97d | 573:716fbe02140a |
---|---|
104 | 104 |
105 InstanceRenderer::~InstanceRenderer() { | 105 InstanceRenderer::~InstanceRenderer() { |
106 } | 106 } |
107 | 107 |
108 void InstanceRenderer::render(Camera* cam, Layer* layer, RenderList& instances) { | 108 void InstanceRenderer::render(Camera* cam, Layer* layer, RenderList& instances) { |
109 // patch #335 by abeyer | |
110 if (!layer->areInstancesVisible()) { | |
111 FL_DBG(_log, "Layer instances hidden"); | |
112 return; | |
113 } | |
114 | |
115 FL_DBG(_log, "Iterating layer..."); | 109 FL_DBG(_log, "Iterating layer..."); |
116 CellGrid* cg = layer->getCellGrid(); | 110 CellGrid* cg = layer->getCellGrid(); |
117 if (!cg) { | 111 if (!cg) { |
118 FL_WARN(_log, "No cellgrid assigned to layer, cannot draw instances"); | 112 FL_WARN(_log, "No cellgrid assigned to layer, cannot draw instances"); |
119 return; | 113 return; |
123 | 117 |
124 RenderList::iterator instance_it = instances.begin(); | 118 RenderList::iterator instance_it = instances.begin(); |
125 for (;instance_it != instances.end(); ++instance_it) { | 119 for (;instance_it != instances.end(); ++instance_it) { |
126 FL_DBG(_log, "Iterating instances..."); | 120 FL_DBG(_log, "Iterating instances..."); |
127 Instance* instance = (*instance_it)->instance; | 121 Instance* instance = (*instance_it)->instance; |
128 InstanceVisual* visual = instance->getVisual<InstanceVisual>(); | |
129 RenderItem& vc = **instance_it; | 122 RenderItem& vc = **instance_it; |
130 unsigned char trans = visual->getTransparency(); | |
131 | |
132 /** | |
133 * the instance transparency value take precedence. If it's 0 use the layer trans | |
134 * | |
135 * \todo Instances cannot be completely opaque when their layer's transparency is non zero. | |
136 */ | |
137 if (trans == 0) { | |
138 unsigned char layer_trans = layer->getLayerTransparency(); | |
139 trans = layer_trans; | |
140 } | |
141 | 123 |
142 FL_DBG(_log, LMsg("Instance layer coordinates = ") << instance->getLocationRef().getLayerCoordinates()); | 124 FL_DBG(_log, LMsg("Instance layer coordinates = ") << instance->getLocationRef().getLayerCoordinates()); |
143 | 125 |
144 if (any_effects) { | 126 if (any_effects) { |
145 InstanceToOutlines_t::iterator outline_it = m_instance_outlines.find(instance); | 127 InstanceToOutlines_t::iterator outline_it = m_instance_outlines.find(instance); |
146 if (outline_it != m_instance_outlines.end()) { | 128 if (outline_it != m_instance_outlines.end()) { |
147 bindOutline(outline_it->second, vc, cam)->render(vc.dimensions, 255-trans); | 129 bindOutline(outline_it->second, vc, cam)->render(vc.dimensions, vc.transparency); |
148 } | 130 } |
149 | 131 |
150 InstanceToColoring_t::iterator coloring_it = m_instance_colorings.find(instance); | 132 InstanceToColoring_t::iterator coloring_it = m_instance_colorings.find(instance); |
151 if (coloring_it != m_instance_colorings.end()) { | 133 if (coloring_it != m_instance_colorings.end()) { |
152 bindColoring(coloring_it->second, vc, cam)->render(vc.dimensions, 255-trans); | 134 bindColoring(coloring_it->second, vc, cam)->render(vc.dimensions, vc.transparency); |
153 continue; // Skip normal rendering after drawing overlay | 135 continue; // Skip normal rendering after drawing overlay |
154 } | 136 } |
155 } | 137 } |
156 | 138 |
157 vc.image->render(vc.dimensions, 255-trans); | 139 vc.image->render(vc.dimensions, vc.transparency); |
158 } | 140 } |
159 } | 141 } |
160 | 142 |
161 Image* InstanceRenderer::bindOutline(OutlineInfo& info, RenderItem& vc, Camera* cam) { | 143 Image* InstanceRenderer::bindOutline(OutlineInfo& info, RenderItem& vc, Camera* cam) { |
162 if (!info.dirty && info.curimg == vc.image) { | 144 if (!info.dirty && info.curimg == vc.image) { |