| 133 | } |
| 134 | |
| 135 | void PointsPrimitive::updateBounds() const |
| 136 | { |
| 137 | if( !m_memberData->recomputeBound ) |
| 138 | { |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | m_memberData->recomputeBound = false; |
| 143 | |
| 144 | if( !m_memberData->points ) |
| 145 | { |
| 146 | m_memberData->bound = Box3f(); |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | unsigned int cwStep = 0, wStep = 0, aStep = 0; |
| 151 | const float *cw = dataAndStride( m_memberData->constantWidth.get(), &MemberData::g_defaultWidth, cwStep ); |
| 152 | const float *w = dataAndStride( m_memberData->widths.get(), &MemberData::g_defaultWidth, wStep ); |
| 153 | const float *a = dataAndStride( m_memberData->patchAspectRatio.get(), &MemberData::g_defaultAspectRatio, aStep ); |
| 154 | |
| 155 | m_memberData->bound.makeEmpty(); |
| 156 | const vector<V3f> &pd = m_memberData->points->readable(); |
| 157 | for( unsigned int i=0; i<pd.size(); i++ ) |
| 158 | { |
| 159 | float r = *cw * *w / 2.0f; cw += cwStep; w += wStep; |
| 160 | if( *a < 1.0f && *a > 0.0f ) |
| 161 | { |
| 162 | r /= *a; |
| 163 | } |
| 164 | a += aStep; |
| 165 | m_memberData->bound.extendBy( Box3f( pd[i] - V3f( r ), pd[i] + V3f( r ) ) ); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | void PointsPrimitive::addPrimitiveVariable( const std::string &name, const IECoreScene::PrimitiveVariable &primVar ) |
| 170 | { |