/// ソート用比較オペレータ public int CompareTo(object obj) { LocalPart lhs = this; LocalPart rhs = (LocalPart)obj; if (lhs.material == null || rhs.material == null) { return(-1); } return(lhs.material.DrawOrder - rhs.material.DrawOrder); }
public override int GetHashCode() { return(((Domain != null ? Domain.GetHashCode() : 0)) ^ (LocalPart != null ? LocalPart.GetHashCode() : 0) ^ Id ^ Tenant); }
/// DrawOrder の実装のため、 SubMesn を LocalPart としてリストに積みなおす private List<LocalPart> updateLocalPart() { List< LocalPart > localPartList = new List< LocalPart >(); foreach ( var bone in Bones ) { int worldCount = 0; int[] blendBones = bone.BlendBones ; if ( blendBones == null ) { worldCount = 1; matrixBuffer = new Matrix4[ 1 ]; matrixBuffer[ 0 ] = bone.WorldMatrix; }else{ int blendCount = blendBones.Length ; if ( blendCount > matrixBuffer.Length ) matrixBuffer = new Matrix4[ blendCount ] ; for ( int i = 0 ; i < blendCount ; i ++ ) { matrixBuffer[ i ] = Bones[ blendBones[ i ] ].WorldMatrix * bone.BlendOffsets[ i ] ; } } int[] blendSubset = defaultBlendSubset ; foreach ( var index in bone.DrawParts ) { BasicPart part = Parts[ index ] ; foreach ( var mesh in part.Meshes ) { if ( blendBones != null && blendSubset != mesh.BlendSubset ) { blendSubset = ( mesh.BlendSubset != null ) ? mesh.BlendSubset : defaultBlendSubset ; worldCount = blendSubset.Length ; if ( worldCount > blendBones.Length ) worldCount = blendBones.Length ; } // パーツの保存 LocalPart localPart = new LocalPart(); if( mesh.Material >= 0 ){ localPart.material = Materials[ mesh.Material ]; }else{ localPart.material = null; } localPart.worldCount = worldCount; localPart.vertexBuffer = mesh.VertexBuffer; localPart.primitives = mesh.Primitives; for( int i = 0; i < worldCount; i++ ){ localPart.matrixPalette[ i ] = matrixBuffer[ blendSubset[ i ] ]; } localPartList.Add( localPart ); } } } return localPartList; }
/// DrawOrder の実装のため、 SubMesn を LocalPart としてリストに積みなおす private List <LocalPart> updateLocalPart() { List <LocalPart> localPartList = new List <LocalPart>(); foreach (var bone in Bones) { int worldCount = 0; int[] blendBones = bone.BlendBones; if (blendBones == null) { worldCount = 1; matrixBuffer = new Matrix4[1]; matrixBuffer[0] = bone.WorldMatrix; } else { int blendCount = blendBones.Length; if (blendCount > matrixBuffer.Length) { matrixBuffer = new Matrix4[blendCount]; } for (int i = 0; i < blendCount; i++) { matrixBuffer[i] = Bones[blendBones[i]].WorldMatrix * bone.BlendOffsets[i]; } } int[] blendSubset = defaultBlendSubset; foreach (var index in bone.DrawParts) { BasicPart part = Parts[index]; foreach (var mesh in part.Meshes) { if (blendBones != null && blendSubset != mesh.BlendSubset) { blendSubset = (mesh.BlendSubset != null) ? mesh.BlendSubset : defaultBlendSubset; worldCount = blendSubset.Length; if (worldCount > blendBones.Length) { worldCount = blendBones.Length; } } // パーツの保存 LocalPart localPart = new LocalPart(); if (mesh.Material >= 0) { localPart.material = Materials[mesh.Material]; } else { localPart.material = null; } localPart.worldCount = worldCount; localPart.vertexBuffer = mesh.VertexBuffer; localPart.primitives = mesh.Primitives; for (int i = 0; i < worldCount; i++) { localPart.matrixPalette[i] = matrixBuffer[blendSubset[i]]; } localPartList.Add(localPart); } } } return(localPartList); }