Mercurial > fife-parpg
changeset 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 | 58c0bbeeeb35 |
files | engine/core/view/layercache.cpp engine/core/view/renderers/instancerenderer.cpp engine/core/view/renderitem.h |
diffstat | 3 files changed, 30 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/core/view/layercache.cpp Wed Jun 30 04:57:35 2010 +0000 +++ b/engine/core/view/layercache.cpp Fri Jul 02 05:49:34 2010 +0000 @@ -283,6 +283,10 @@ void LayerCache::update(Camera::Transform transform, RenderList& renderlist) { const double OVERDRAW = 2.5; renderlist.clear(); + if(!m_layer->areInstancesVisible()) { + FL_DBG(_log, "Layer instances hidden"); + return; + } bool isWarped = transform == Camera::WarpedTransform; if( isWarped ) fullUpdate(); @@ -296,6 +300,7 @@ viewport.y = std::min(viewport_a.y, viewport_b.y); viewport.w = std::max(viewport_a.x, viewport_b.x) - viewport.x; viewport.h = std::max(viewport_a.y, viewport_b.y) - viewport.y; + unsigned char layer_trans = m_layer->getLayerTransparency(); // FL_LOG(_log, LMsg("camera-update viewport") << viewport); std::vector<int> index_list; @@ -313,8 +318,24 @@ RenderItem& item = m_instances[entry.instance_index]; InstanceVisual* visual = item.instance->getVisual<InstanceVisual>(); bool visible = visual->isVisible(); - if(!item.image || !visible) + unsigned char instance_trans = visual->getTransparency(); + if(!item.image || !visible || (instance_trans == 255 && layer_trans == 0) + || (instance_trans == 0 && layer_trans == 255)) { continue; + } + + if(layer_trans != 0) { + if(instance_trans != 0) { + short calc_trans = layer_trans - instance_trans; + if(calc_trans >= 0) { + instance_trans = calc_trans; + } else { + instance_trans = 0; + } + } else { + instance_trans = layer_trans; + } + } Point3D screen_point = m_camera->virtualScreenToScreen(item.screenpoint); // NOTE: @@ -328,6 +349,8 @@ item.dimensions.w = item.bbox.w; item.dimensions.h = item.bbox.h; + item.transparency = 255 - instance_trans; + if (zoom != 1.0) { // NOTE: Due to image alignment, there is additional additions on image dimensions // There's probabaly some better solution for this, but works "good enough" for now.
--- a/engine/core/view/renderers/instancerenderer.cpp Wed Jun 30 04:57:35 2010 +0000 +++ b/engine/core/view/renderers/instancerenderer.cpp Fri Jul 02 05:49:34 2010 +0000 @@ -106,12 +106,6 @@ } void InstanceRenderer::render(Camera* cam, Layer* layer, RenderList& instances) { - // patch #335 by abeyer - if (!layer->areInstancesVisible()) { - FL_DBG(_log, "Layer instances hidden"); - return; - } - FL_DBG(_log, "Iterating layer..."); CellGrid* cg = layer->getCellGrid(); if (!cg) { @@ -125,36 +119,24 @@ for (;instance_it != instances.end(); ++instance_it) { FL_DBG(_log, "Iterating instances..."); Instance* instance = (*instance_it)->instance; - InstanceVisual* visual = instance->getVisual<InstanceVisual>(); RenderItem& vc = **instance_it; - unsigned char trans = visual->getTransparency(); - - /** - * the instance transparency value take precedence. If it's 0 use the layer trans - * - * \todo Instances cannot be completely opaque when their layer's transparency is non zero. - */ - if (trans == 0) { - unsigned char layer_trans = layer->getLayerTransparency(); - trans = layer_trans; - } FL_DBG(_log, LMsg("Instance layer coordinates = ") << instance->getLocationRef().getLayerCoordinates()); if (any_effects) { InstanceToOutlines_t::iterator outline_it = m_instance_outlines.find(instance); if (outline_it != m_instance_outlines.end()) { - bindOutline(outline_it->second, vc, cam)->render(vc.dimensions, 255-trans); + bindOutline(outline_it->second, vc, cam)->render(vc.dimensions, vc.transparency); } InstanceToColoring_t::iterator coloring_it = m_instance_colorings.find(instance); if (coloring_it != m_instance_colorings.end()) { - bindColoring(coloring_it->second, vc, cam)->render(vc.dimensions, 255-trans); + bindColoring(coloring_it->second, vc, cam)->render(vc.dimensions, vc.transparency); continue; // Skip normal rendering after drawing overlay } } - vc.image->render(vc.dimensions, 255-trans); + vc.image->render(vc.dimensions, vc.transparency); } }
--- a/engine/core/view/renderitem.h Wed Jun 30 04:57:35 2010 +0000 +++ b/engine/core/view/renderitem.h Fri Jul 02 05:49:34 2010 +0000 @@ -64,6 +64,9 @@ // current facing angle int facing_angle; + + // current transparency + unsigned char transparency; private: int m_cached_static_img_id; int m_cached_static_img_angle;