public void PostRenderCommand(Vector position, float z_orther, float rotate, Vector scale, HalfVector anchor, ByteVec4 color, bool vertical_flip, bool horizon_flip) => PostRenderCommand(position, z_orther, _bound, rotate, scale, anchor, color, vertical_flip, horizon_flip);
public static Anchor?Convert(HalfVector offset) { return(AnchorVectorMap.Where(x => x.Value == offset).Select(x => x.Key).FirstOrDefault()); }
public void PostRenderCommand(Vector position, float z_other, Vector bound, float rotate, Vector scale, HalfVector anchor, ByteVec4 color, bool vertical_flip, bool horizon_flip) { /*-----------------CURRENT VERSION------------------ - * anchor(Hlaf) color(byte) modelMatrix * vec2(2) vec4(4) Matrix3x2(6) */ var is_xflip = Math.Sign(scale.X); var is_yflip = Math.Sign(scale.Y); //adjust scale transform which value is negative horizon_flip = horizon_flip | (is_xflip < 0); vertical_flip = vertical_flip | (is_yflip < 0); float scalex = is_xflip * scale.X * bound.X; float scaley = is_yflip * scale.Y * bound.Y; //Create ModelMatrix float cosa = (float)Math.Cos(rotate); float sina = (float)Math.Sin(rotate); Matrix3x2 model = Matrix3x2.Zero; model.Row0.X = cosa * scalex; model.Row0.Y = -sina * scalex; model.Row1.X = sina * scaley; model.Row1.Y = cosa * scaley; model.Row2.X = position.X - RenderKernel.SB_WIDTH / 2f; model.Row2.Y = -position.Y + RenderKernel.SB_HEIGHT / 2f; unsafe { //Anchor write fixed(byte *ptr = &PostData[_currentPostBaseIndex]) { //anchor int *hpv = (int *)(ptr + 0); *hpv = *(int *)&anchor; //color int *ip = (int *)(ptr + 4); *ip = *(int *)&color; //flip write Half *hp = (Half *)(ptr + 8); hp[0] = horizon_flip ? HalfNegativeOne : HalfOne; hp[1] = vertical_flip ? HalfNegativeOne : HalfOne; var copyLen = 2 * 3 * sizeof(float); var basePtr = (byte *)&model.Row0.X; for (int i = 0; i < copyLen; i++) { ptr[i + 12] = *(basePtr + i); } } } CurrentPostCount++; _currentPostBaseIndex += _VertexSize; if (CurrentPostCount >= Capacity) { FlushDraw(); } }