public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys) { _worldSph = World; if (Spin != Vector3.Zero) { _worldSph = (Matrix4x4.CreateRotationX((float)spinX) * Matrix4x4.CreateRotationY((float)spinY) * Matrix4x4.CreateRotationZ((float)spinZ)) * World; } this.sysr = sys; if (Nebula != null && nr != Nebula) { return(false); } var dsq = Vector3.DistanceSquared(pos, camera.Position); if (LODRanges != null) //Fastest cull { var maxd = LODRanges[LODRanges.Length - 1] * sysr.LODMultiplier; maxd *= maxd; if (dsq > maxd) { CurrentLevel = -1; return(false); } } bool visible = false; if (Model != null) { visibleParts = new BitArray128(); for (int i = 0; i < Model.AllParts.Length; i++) { var part = Model.AllParts[i]; if (!part.Active || part.Mesh == null) { continue; } var center = Vector3.Transform(part.Mesh.Center, part.LocalTransform * World); var lvl = GetLevel(part, center, camera.Position); if (lvl != -1) { var bsphere = new BoundingSphere(center, part.Mesh.Radius); if (camera.Frustum.Intersects(bsphere)) { visible = true; visibleParts[i] = true; } } } } if (visible) { sysr.AddObject(this); } return(visible); }
public bool Equals(BitArray128 other) { return(a == other.a && b == other.b); }