public void UpdateRotation(LFloat deg) { }
public static int Sign(LFloat val) { return(System.Math.Sign(val._val)); }
public static LFloat Lerp(LFloat a, LFloat b, LFloat f) { return(new LFloat(true, (int)(((long)(b._val - a._val) * f._val) / LFloat.Precision) + a._val)); }
public static LFloat Atan2(LFloat y, LFloat x) { return(Atan2(y._val, x._val)); }
public static LFloat Sqr(LFloat a) { return(a * a); }
public void setEndX(LFloat endX) { this.endX = endX; }
public void setWidth(LFloat width) { this.width = width; }
public T Add(T node, LFloat value) { node.value = value; return(Add(node)); }
public static bool TestAABBAABB(LVector2 posA, LFloat rA, LVector2 sizeA, LVector2 posB, LFloat rB, LVector2 sizeB) { var diff = posA - posB; var allRadius = rA + rB; //circle 判定 if (diff.sqrMagnitude > allRadius * allRadius) { return(false); } var absX = LMath.Abs(diff.x); var absY = LMath.Abs(diff.y); //AABB and AABB var allSize = sizeA + sizeB; if (absX > allSize.x) { return(false); } if (absY > allSize.y) { return(false); } return(true); }
public int index; //节点索引 public Node(LFloat value) { this.value = value; }
private void Down(int index) { Node[] nodes = this._nodes; int size = this.size; Node node = nodes[index]; LFloat value = node.value; while (true) { int leftIndex = 1 + (index << 1); if (leftIndex >= size) { break; } // Always have a left child. Node leftNode = nodes[leftIndex]; LFloat leftValue = leftNode.value; // May have a right child. int rightIndex = leftIndex + 1; Node rightNode; LFloat rightValue; if (rightIndex >= size) { rightNode = null; rightValue = _isMaxHeap ? LFloat.MinValue : LFloat.MaxValue; } else { rightNode = nodes[rightIndex]; rightValue = rightNode.value; } // The smallest of the three values is the parent. if ((leftValue < rightValue) ^ _isMaxHeap) { if (leftValue == value || ((leftValue > value) ^ _isMaxHeap)) { break; } nodes[index] = leftNode; leftNode.index = index; index = leftIndex; } else { if (rightValue == value || ((rightValue > value) ^ _isMaxHeap)) { break; } nodes[index] = rightNode; rightNode.index = index; index = rightIndex; } } nodes[index] = node; node.index = index; }
public virtual void DoUpdate(LFloat deltaTime) { }
private void Step() { if (_commonStateService.IsPause) { return; } _commonStateService.SetTick(Tick); var hash = GetHash(); if (_constStateService.IsClientMode) { if (_tick2Hash.TryGetValue(Tick, out var val)) { _tick2ResumeDumpString[Tick] = DumpStr(); if (hash != val) { Debug.LogError($"Tick : CurHash {hash} is different from oldHash {val}"); #if UNITY_EDITOR var path = dumpPath + "/cur.txt"; var dir = Path.GetDirectoryName(path); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var minTick = _tick2ResumeDumpString.Keys.Min(); StringBuilder sbResume = new StringBuilder(); StringBuilder sbRaw = new StringBuilder(); for (int i = minTick; i <= Tick; i++) { sbRaw.AppendLine(_tick2RawDumpString[i].ToString()); sbResume.AppendLine(_tick2ResumeDumpString[i].ToString()); } File.WriteAllText(dumpPath + "/resume.txt", sbResume.ToString()); File.WriteAllText(dumpPath + "/raw.txt", sbRaw.ToString()); _commonStateService.IsPause = true; UnityEngine.Debug.Break(); #endif } } else { _tick2RawDumpString[Tick] = DumpStr(); } } _commonStateService.Hash = hash; _tick2Hash[Tick] = hash; _timeMachineService.Backup(Tick); var deltaTime = new LFloat(true, 30); foreach (var system in _systems) { if (system.enable) { system.DoUpdate(deltaTime); } } Tick++; }
public static int GetHash(this LFloat val) { return(PrimerLUT.GetPrimer(val._val)); }
public void setStartX(LFloat startX) { this.startX = startX; }
public static LVector3 scl(this LVector3 vec, LFloat val) { return(vec * val); }
public void setStartZ(LFloat startZ) { this.startZ = startZ; }
public static LFloat dot(this LVector3 vec, LFloat x, LFloat y, LFloat z) { return(LVector3.Dot(vec, new LVector3(x, y, z))); }
public void setEndZ(LFloat endZ) { this.endZ = endZ; }
public static LVector3 cross(this LVector3 vec, LFloat x, LFloat y, LFloat z) { return(new LVector3(vec.y * z - vec.z * y, vec.z * x - vec.x * z, vec.x * y - vec.y * x)); }
public void setHeight(LFloat height) { this.height = height; }
public static LFloat dst2(LFloat x1, LFloat z1, LFloat x2, LFloat z2) { x1 -= x2; z1 -= z2; return(x1 * x1 + z1 * z1); }
//ccw public static LFloat Cos(LFloat radians) { int index = LUTSinCos.getIndex(radians); return(new LFloat(true, (long)LUTSinCos.cos_table[index] / 10)); }
//add public void AddCircle(LVector2 offset, LVector2 pos, LFloat radius) { allColliders.Add(new Circle(pos, radius)); allOffsets.Add(offset); }
public static bool SameSign(LFloat a, LFloat b) { return((long)a._val * b._val > 0L); }
public void AddOBB(LVector2 offset, LVector2 pos, LVector2 size, LFloat deg) { allColliders.Add(new OBB(pos, size, deg)); allOffsets.Add(offset); }
public static LFloat Max(LFloat a, LFloat b) { return(new LFloat(true, Max(a._val, b._val))); }
public void SetRotation(LFloat val) { transform.rotation = Quaternion.Euler(0, 0, val.ToFloat()); OnSetRotation(val); }
public static LVector2 Lerp(LVector2 a, LVector2 b, LFloat f) { return(new LVector2(true, (int)(((long)(b._x - a._x) * f._val) / LFloat.Precision) + a._x, (int)(((long)(b._y - a._y) * f._val) / LFloat.Precision) + a._y)); }
public Circle(int id, LVector2 pos, LFloat radius) : this((int)EShape2D.Circle, id, pos, radius) { }