public half4(half x, half y, half z, half w) { this.x = x; this.y = y; this.z = z; this.w = w; }
public void Execute(Entity entity, int index, ref EnemyComponent enemy) { results = 0; if (enemy.health <= 0) { results = 1; entityCommandBuffer.DestroyEntity(index, entity); } }
private void Update() { if (tt >= maxt) { tt = 0f; } tt += Time.deltaTime; }
public DebuggerProxy(half8 v) { x0 = v.x0; x1 = v.x1; x2 = v.x2; x3 = v.x3; x4 = v.x4; x5 = v.x5; x6 = v.x6; x7 = v.x7; }
public void ChangeHealth(half changeValue) { healthValue += changeValue; if (healthValue < 0) { healthValue = 0; } if (healthValue > 2) { healthValue = 2; } }
public float9(half v) { r0 = v; r1 = v; r2 = v; r3 = v; r4 = v; r5 = v; r6 = v; r7 = v; r8 = v; }
/// <summary> /// Conversion of variance to a side int /// </summary> /// <remarks>This is essentially performing the same function as the <see cref="SplineSide"/> enum</remarks> /// <param name="variance">variance to convert</param> /// <returns>int code for the spline</returns> private static int VarianceToSide(half variance) { if (variance > 0) { return(2); // Right } if (variance < 0) { return(1); // Left } return(0); // Center }
public void Execute(int index) { half distance = math.distance(bombPosition, position[index].Value); if (distance < 4) { float3 force = math_experimental.normalizeSafe(position[index].Value - bombPosition); force.y = 5f; force = force * (4 - distance); velocityBarrier.AddComponent(dummies[index], new Velocity { Value = force }); velocityBarrier.AddComponent(dummies[index], default(GravityType)); velocityBarrier.RemoveComponent <MoveForward>(dummies[index]); } }
/// <summary> /// Method that actually calculates the bezier spline with variance /// </summary> /// <param name="t">progress X for center spline, Y for side spline</param> /// <param name="spline1">center spline index</param> /// <param name="spline2">side spline index</param> /// <param name="variance">deviation from center</param> /// <returns>final cubic variance position</returns> private float2 CubicBezierPoint(float2 t, int spline1, int spline2, half variance) { //center spline float2x4 a = new float2x4( Spline.Points[spline1 * 9 + 0], Spline.Points[spline1 * 9 + 3], Spline.Points[(spline1 + 1) * 9 - 3], Spline.Points[(spline1 + 1) * 9 + 0]); float2x4 b; if (variance > 0) { // Right spline b = new float2x4( Spline.Points[spline2 * 9 + 2], Spline.Points[spline2 * 9 + 5], Spline.Points[(spline2 + 1) * 9 - 1], Spline.Points[(spline2 + 1) * 9 + 2]); } else { // Left spline b = new float2x4( Spline.Points[spline2 * 9 + 1], Spline.Points[spline2 * 9 + 4], Spline.Points[(spline2 + 1) * 9 - 2], Spline.Points[(spline2 + 1) * 9 + 1]); } float2 oneMinusT = 1f - t; return(math.lerp( (oneMinusT.x * oneMinusT.x * oneMinusT.x * a.c0) + (3f * oneMinusT.x * oneMinusT.x * t.x * a.c1) + (3f * oneMinusT.x * t.x * t.x * a.c2) + (t.x * t.x * t.x * a.c3), (oneMinusT.y * oneMinusT.y * oneMinusT.y * b.c0) + (3f * oneMinusT.y * oneMinusT.y * t.y * b.c1) + (3f * oneMinusT.y * t.y * t.y * b.c2) + (t.y * t.y * t.y * b.c3), math.abs(variance))); }
public void Combine(ref half curr, ref half value) { curr += value; }
public static bool toboolsafe(half a) { return((float)a != 0f); }
public void GetIdentity(out half identity) { identity = (half)0; }
public static bool isnan(half h) { return((h.value & 0x7FFF) > 0x7C00); }
public static bool IsPositiveInfinity(half half) { return (half.value == 0x7c00); }
public half8(half x0, half x1, half x2, half x3, half x4, half x5, half x6, half x7) { this = maxmath.ashalf(new ushort8(x0.value, x1.value, x2.value, x3.value, x4.value, x5.value, x6.value, x7.value)); }
public static void half_from_double_explicit_conversion() { half h = (half)123.4; TestUtils.AreEqual(0x57B6, h.value); }
public static float Float3Half(float a) { var h = new half(a); return(Vectors.ConvertToFloat((float3) new float3(h).x)); }
public half2(half x, half y) { this.x = x; this.y = y; }
public static half Abs(half half) { return half.ToHalf((ushort)(half.value & 0x7fff)); }
public static double Double2Half(double a) { var h = new half(a); return(Vectors.ConvertToDouble((double2) new double2(h).x)); }
public static ushort asushort(half x) { return(x.value); }
public static short asshort(half x) { return((short)x.value); }
public static bool isinf(half h) { return((h.value & 0x7FFF) == 0x7C00); }
// The code actually running on the job public void Execute(int i) { if (i >= offsetLength.x && i < offsetLength.y - offsetLength.x) { var waveCountMulti = 1f / waveData.Length; float3 wavePos = new float3(0f, 0f, 0f); float3 waveNorm = new float3(0f, 0f, 0f); for (var wave = 0; wave < waveData.Length; wave++) // for each wave { // Wave data vars float2 pos = position[i].xz; var amplitude = waveData[wave].amplitude; var direction = waveData[wave].direction; var wavelength = waveData[wave].wavelength; float2 omniPos = waveData[wave].origin; ////////////////////////////////wave value calculations////////////////////////// half w = 6.28318f / wavelength; // 2pi over wavelength(hardcoded) half wSpeed = math.sqrt(9.8f * w); // frequency of the wave based off wavelength half peak = 0.8f; // peak value, 1 is the sharpest peaks half qi = peak / (amplitude * w * waveData.Length); float2 windDir = new float2(0f, 0f); float dir = 0; direction = math.radians(direction); // convert the incoming degrees to radians half2 windDirInput = new float2(math.sin(direction), math.cos(direction)) * (1 - waveData[wave].onmiDir); // calculate wind direction - TODO - currently radians half2 windOmniInput = (pos - omniPos) * waveData[wave].onmiDir; windDir += windDirInput; windDir += windOmniInput; windDir = math.normalize(windDir); dir = math.dot(windDir, pos - (omniPos * waveData[wave].onmiDir)); // calculate a gradient along the wind direction ////////////////////////////position output calculations///////////////////////// float calc = dir * w + -time * wSpeed; // the wave calculation float cosCalc = math.cos(calc); // cosine version(used for horizontal undulation) float sinCalc = math.sin(calc); // sin version(used for vertical undulation) // calculate the offsets for the current point wavePos.x += qi * amplitude * windDir.x * cosCalc; wavePos.z += qi * amplitude * windDir.y * cosCalc; wavePos.y += ((sinCalc * amplitude)) * waveCountMulti; // the height is divided by the number of waves if (normal == 1) { ////////////////////////////normal output calculations///////////////////////// half wa = w * amplitude; // normal vector float3 norm = new float3(-(windDir.xy * wa * cosCalc), 1 - (qi * wa * sinCalc)); waveNorm += (norm * waveCountMulti) * amplitude; } } outPosition[i] = wavePos; if (normal == 1) { outNormal[i] = math.normalize(waveNorm.xzy); } } }
public static void half_maxvalue() { half max = new half(half.MaxValue); TestUtils.AreEqual(0x7bff, max.value); }
public static half Negate(half half) { return half.ToHalf((ushort)(half.value ^ 0x8000)); }
public static bool IsNegativeInfinity(half half) { return (half.value == 0xfc00); }
public half8(half x0x8) { this = maxmath.ashalf(new ushort8(x0x8.value)); }
public static bool IsInfinity(half half) { return ((half.value & 0x7fff) == 0x7c00); }
public static void half_minvalue() { half min = new half(half.MinValue); TestUtils.AreEqual(0xfbff, min.value); }
public static bool isfinite(half h) { return((h.value & 0x7FFF) < 0x7C00); }
public static float HalfToSingle(half half) { UintFloatUnion u; u.b = 0; u.a = mantissaTable[offsetTable[half.value >> 10] + (half.value & 0x3ff)] + exponentTable[half.value >> 10]; return u.b; }
public void GetIdentity(out half identity) { identity = half.MinValue; }
public void Execute(int index) { index = dirty_indices[index]; var data = build_trans_data[index]; // 顶点索引偏移 int valid_quad_count = data.valid_quad; int base_index = data.index * quad_count * 4; int per_quad_index = data.per_quad_index; float3 position = data.local_position; bool is_text = data.is_text == 1; float is_text_flag = is_text ? 1 : 0; half progress = data.extend.x; var gscale = data.gscale; var scale = data.local_scale * HUDBatch.default_unit / 2 * gscale; float2 sdf_scale = new float2(is_text_flag, scale.y); float left_x = position.x; for (int i = 0; i < valid_quad_count; ++i) { int vertex_offset = base_index + i * 4; var quad_data = build_quad_data[per_quad_index + i]; var half_size = quad_data.size / 2; Vertex v0 = vertices[vertex_offset + 0]; Vertex v1 = vertices[vertex_offset + 1]; Vertex v2 = vertices[vertex_offset + 2]; Vertex v3 = vertices[vertex_offset + 3]; if ((data.flag & DirtyFlag.ETransform) != DirtyFlag.ENone) { var p = position; p.z = 0; var tparams = quad_data.tparams; if (is_text) { // lt p.x = position.x + (tparams.z - font_uv_padding) * scale.x; p.y = position.y + (tparams.w + font_uv_padding) * scale.y; v1.position = p; // record top y float ty = p.y; // lb //p.x = p.x; p.y = p.y - ((tparams.y + font_uv_padding * 2) * scale.y); v0.position = p; // record bottom y float by = p.y; // rt p.x = p.x + ((tparams.x + font_uv_padding * 2) * scale.x); p.y = ty; v2.position = p; // rb //p.x = p.x; p.y = by; v3.position = p; position.x = p.x + data.spacing; } else { float lx = position.x; float rx = position.x + scale.x * half_size.x * 2; //lb p.x = lx; p.y = position.y - scale.y * half_size.y; v0.position = p; //lt p.y = position.y + scale.y * half_size.y; v1.position = p; p.x = lx + (rx - lx) * progress; //rt p.y = position.y + scale.y * half_size.y; v2.position = p; //rb p.y = position.y - scale.y * half_size.y; v3.position = p; position.x += rx + data.spacing; } v1.uv1 = v2.uv1 = v3.uv1 = v0.uv1 = sdf_scale; } if ((data.flag & DirtyFlag.EQuad) != DirtyFlag.ENone) { v0.color = v1.color = v2.color = v3.color = quad_data.color; // uv0 // uv1 pack 到uv0 float2 uv_0 = float2.zero; float4 rect = quad_data.uv0; float xmin, xmax, ymin, ymax; if (is_text) { xmin = (rect.x - font_uv_padding) / fontAltas_width; xmax = (rect.x + font_uv_padding + rect.z) / fontAltas_width; ymin = (rect.y - font_uv_padding) / fontAltas_height; ymax = (rect.y + font_uv_padding + rect.w) / fontAltas_height; } else { xmin = (rect.x); xmax = (rect.x + rect.z); ymin = (rect.y); ymax = (rect.y + rect.w); } uv_0.x = xmin; uv_0.y = ymin; v0.uv0 = uv_0; uv_0.y = ymax; v1.uv0 = uv_0; uv_0.x = xmin + (xmax - xmin) * progress; v2.uv0 = uv_0; uv_0.y = ymin; v3.uv0 = uv_0; } vertices[vertex_offset + 0] = v0; vertices[vertex_offset + 1] = v1; vertices[vertex_offset + 2] = v2; vertices[vertex_offset + 3] = v3; } float h_size = (position.x - left_x - data.spacing) / 2; for (int i = 0; i < valid_quad_count; ++i) { int vertex_offset = base_index + i * 4; Vertex v0 = vertices[vertex_offset + 0]; Vertex v1 = vertices[vertex_offset + 1]; Vertex v2 = vertices[vertex_offset + 2]; Vertex v3 = vertices[vertex_offset + 3]; v0.position.x -= h_size; v1.position.x -= h_size; v2.position.x -= h_size; v3.position.x -= h_size; vertices[vertex_offset + 0] = v0; vertices[vertex_offset + 1] = v1; vertices[vertex_offset + 2] = v2; vertices[vertex_offset + 3] = v3; } data.flag = DirtyFlag.ENone; build_trans_data[index] = data; }
public static bool IsNaN(half half) { return ((half.value & 0x7fff) > 0x7c00); }
public half3(half x, half y, half z) { this.x = x; this.y = y; this.z = z; }
public void Combine(ref half curr, ref half value) { curr = value > curr ? value : curr; }