void StyleHelper::horizontalHeader( QPainter* painter, const QRect& r ) { painter->save(); QRect upperHalf( 0, 0, r.width(), r.height() / 2 ); QRect lowerHalf( 0, upperHalf.height(), r.width(), r.height() ); painter->fillRect( upperHalf, StyleHelper::headerUpperColor() ); painter->fillRect( lowerHalf, StyleHelper::headerLowerColor() ); { QColor lineColor( 100, 100, 100 ); QLine line( 0, 0, r.width(), 0 ); painter->setPen( lineColor ); painter->drawLine( line ); } { QColor lineColor( 30, 30, 30 ); QLine line( 0, r.height() - 1, r.width(), r.height() - 1 ); painter->setPen( lineColor ); painter->drawLine( line ); } painter->restore(); }
//---------------------------------------------------------------------------------- // BVH node BVHNode::BVHNode(const HitableListRef &aList, float aTime0, float aTime1) { size_t n = aList->list().size(); // pick an axis to sort along int axis = static_cast<int>(3.0f * randFloat()); // sort along the chosen axis switch (axis) { case 0: // x std::sort(aList->list().begin(), aList->list().end(), comparator(0)); break; case 1: // y std::sort(aList->list().begin(), aList->list().end(), comparator(1)); break; case 2: // z std::sort(aList->list().begin(), aList->list().end(), comparator(2)); break; default: break; } if (n == 1) // one element { mLeft = mRight = aList->list().at(0); } if (n == 2) // two elements { mLeft = aList->list().at(0); mRight = aList->list().at(1); } else // split in half { size_t half_size = aList->list().size() / 2; std::vector<HitableRef> lowerHalf(aList->list().begin(), aList->list().begin() + half_size); std::vector<HitableRef> upperHalf(aList->list().begin() + half_size, aList->list().end()); HitableListRef low = HitableList::create(lowerHalf); HitableListRef high = HitableList::create(upperHalf); mLeft = create(low, aTime0, aTime1); mRight = create(high, aTime0, aTime1); } AABB boxLeft; AABB boxRight; if (!mLeft->boundingBox(aTime0, aTime1, boxLeft) || !mRight->boundingBox(aTime0, aTime1, boxRight)) { std::cerr << "No bounding box in BVH node constructor." << std::endl; } mBox = enclosingBox(boxLeft, boxRight); }