void RayTracingEnvironment::AddToRayStream(RayStream &s, Vector const &start,Vector const &end, RayTracingSingleResult *rslt_out) { Vector delta=end; delta-=start; int msk=GetSignMask(delta); assert(msk>=0); assert(msk<8); int pos=s.n_in_stream[msk]; assert(pos<4); s.PendingRays[msk].origin.X(pos)=start.x; s.PendingRays[msk].origin.Y(pos)=start.y; s.PendingRays[msk].origin.Z(pos)=start.z; s.PendingRays[msk].direction.X(pos)=delta.x; s.PendingRays[msk].direction.Y(pos)=delta.y; s.PendingRays[msk].direction.Z(pos)=delta.z; s.PendingStreamOutputs[msk][pos]=rslt_out; if (pos==3) { FlushStreamEntry(s,msk); } else s.n_in_stream[msk]++; }
bool JavascriptSIMDFloat64x2::GetPropertyBuiltIns(PropertyId propertyId, Var* value, ScriptContext* requestContext) { switch (propertyId) { case PropertyIds::toString: *value = requestContext->GetLibrary()->GetSIMDFloat64x2ToStringFunction(); return true; case PropertyIds::signMask: *value = GetSignMask(); return true; } return false; }
void Octree2::BuildOctreeRecursive( int parentX, int parentY, int parentZ, int parentRadius, const AVolume* _volume, int parentIndex ) { // determine the center and extent of each child octant const OctCubeI parent = { parentX, parentY, parentZ, parentRadius }; OctCubeI childOctants[8]; for( int i = 0; i < 8; i++ ) { childOctants[i] = GetChildOctant( parent, i ); } #if 0 // relative offset of the array of children of this node int childrenOffset = m_nodes.Num() - parentIndex; // figure out which octants need further subdividing int childMask = 0; for( int i = 0; i < 8; i++ ) { const OctreeNode child = childOctants[i]; if( NeedsSubdivision(child.x, child.y, child.z, child.w, _volume)) { childMask |= (1 << i); } } int signMask = GetSignMask( parentX, parentY, parentZ, parentRadius, _volume ); if(!childMask) { //DBGOUT("Node[%u]: childMask==0 (%d,%d,%d,%d)\n", parentIndex, parentX, parentY, parentZ, parentSize); //float density = _volume->SampleAt( parentX, parentY, parentZ ); //bool isSolid = (density < 0.0f); //if( isSolid ) //{ // //const Float3 N = _volume->GetNormal(parentX, parentY, parentZ); // //const UByte4 packed = { _NormalToUInt8(N.x), _NormalToUInt8(N.y), _NormalToUInt8(N.z), 0 }; // //m_nodes[ parentIndex ] = (packed.v << 8); // m_nodes[ parentIndex ] = 0; //} bool isBlackLeaf = (signMask == 0xFF); if(isBlackLeaf){ m_nodes[ parentIndex ] = 0; return; } bool isWhiteLeaf = (signMask == 0x00); if(isWhiteLeaf){ // empty nodes are not stored UINT32 vv = m_nodes[ parentIndex ]; return; } // this is a gray leaf const Float3 N = _volume->GetNormal(parentX, parentY, parentZ); const UByte4 packed = { _NormalToUInt8(N.x), _NormalToUInt8(N.y), _NormalToUInt8(N.z), 0 }; m_nodes[ parentIndex ] = (packed.v << 8); return; } const int numKids = s_BitCount[ childMask ]; if( parentRadius == 1 ) { for( int i = 0; i < 8; i++ ) { if( childMask & (1<<i) ) { const OctreeNode child = childOctants[i]; const Float3 N = _volume->GetNormal(child.x, child.y, child.z); const UByte4 packed = { _NormalToUInt8(N.x), _NormalToUInt8(N.y), _NormalToUInt8(N.z), 0 }; m_nodes.Add(packed.v); } } } else { UINT32 childIndex = m_nodes.Num(); m_nodes.AddZeroed(numKids); for( int i = 0; i < 8; i++ ) { if( childMask & (1<<i) ) { const OctreeNode child = childOctants[i]; BuildOctreeRecursive(child.x, child.y, child.z, child.w, _volume, childIndex++); } } } mxASSERT(childMask); m_nodes[ parentIndex ] = (childrenOffset << 8) | childMask; //DBGOUT("Node[%u]: %u kids at %u (%d,%d,%d,%d)\n", parentIndex, numKids, childrenOffset, parentX, parentY, parentZ, parentSize); #endif }