/// <summary> /// Alternative to OverwriteUpperBits that attempts to guess the upperbits by seeing if each axis of the new position would be /// closer to the old one if the upper bit is incremented by one, two, three etc. Stops trying when it fails to get a better result. /// </summary> /// <param name="oldcpos">Last best position test against.</param> /// <returns>Returns a corrected CompressPos</returns> public static void GuessUpperBits(this CompressedElement newcpos, ElementCrusher ec, CompressedElement oldcpos, BitCullingLevel bcl) { //var crusher = oldcpos.crusher; newcpos.Set( ec, ec.XCrusher.GuessUpperBits(newcpos[0], oldcpos[0], bcl), ec.YCrusher.GuessUpperBits(newcpos[1], oldcpos[1], bcl), ec.ZCrusher.GuessUpperBits(newcpos[2], oldcpos[2], bcl) ); }
//public static CompressedElement OverwriteUpperBits(this CompressedElement low, CompressedElement up, FloatCrusher[] ec, BitCullingLevel bcl) //{ // return new CompressedElement( // //ec, // ec[0].OverwriteUpperBits(low.cx, up.cx, bcl), // ec[1].OverwriteUpperBits(low.cy, up.cy, bcl), // ec[2].OverwriteUpperBits(low.cz, up.cz, bcl) // ); //} public static void ZeroLowerBits(this CompressedElement fullpos, CompressedElement target, BitCullingLevel bcl) { ElementCrusher ec = fullpos.crusher; target.Set( ec, //fullpos.crusher, ec.XCrusher.ZeroLowerBits(fullpos.cx, bcl), ec.YCrusher.ZeroLowerBits(fullpos.cy, bcl), ec.ZCrusher.ZeroLowerBits(fullpos.cz, bcl) ); }
//public static CompressedElement GuessUpperBits(this CompressedElement newcpos, CompressedElement oldcpos, FloatCrusher[] ec, BitCullingLevel bcl) //{ // var crusher = oldcpos.crusher; // return new CompressedElement( // crusher, // new CompressedValue(crusher.xcrusher, ec[0].GuessUpperBits(newcpos.cx, oldcpos.cx, bcl), crusher.xcrusher.GetBits(bcl)), // new CompressedValue(crusher.ycrusher, ec[1].GuessUpperBits(newcpos.cx, oldcpos.cx, bcl), crusher.xcrusher.GetBits(bcl)), // new CompressedValue(crusher.zcrusher, ec[2].GuessUpperBits(newcpos.cx, oldcpos.cx, bcl), crusher.xcrusher.GetBits(bcl)) // ); //} /// <summary> /// Replace the upperbits of the first compressed element with the upper bits of the second, using BitCullingLevel as the separation point. /// </summary> public static void OverwriteUpperBits(this CompressedElement low, CompressedElement uppers, BitCullingLevel bcl) { ElementCrusher ec = low.crusher; low.Set( ec, ec.XCrusher.OverwriteUpperBits(low.cx, uppers.cx, bcl), ec.YCrusher.OverwriteUpperBits(low.cy, uppers.cy, bcl), ec.ZCrusher.OverwriteUpperBits(low.cz, uppers.cz, bcl) ); }