private void SetValueAtIndex(int index, float value, IShelterObj obj, int bordIndex, Point bordp) { if (index < 0 || index >= depthMap.Length) { return; } if (value < depthMap[index]) { depthMap[index] = value; objMap[index] = obj; objBordIndexMap[index] = new VisiBordPoint(bordIndex, bordp); } }
public void ApplyShelterObj(Rader rader, IShelterObj obj) { Matrix worldMatrix = obj.WorldTrans; CircleList <BorderPoint> border = obj.BorderData; CircleListNode <BorderPoint> lastB = border.First.pre; Vector2 pInRader = rader.TranslateToRaderSpace(Vector2.Transform(ConvertHelper.PointToVector2(lastB.value.p), worldMatrix)); int lastIndex = IndexOf(pInRader.X); float lastDepth = pInRader.Y; CircleListNode <BorderPoint> cur = border.First; for (int i = 0; i < border.Length; i++) { pInRader = rader.TranslateToRaderSpace(Vector2.Transform(ConvertHelper.PointToVector2(cur.value.p), worldMatrix)); int curIndex = IndexOf(pInRader.X); float curDepth = pInRader.Y; if (pInRader.X >= -1.1f && pInRader.X <= 1.3f) { //this[pInRader.X] = Math.Min( this[pInRader.X], pInRader.Y ); SetValueAtIndex(curIndex, pInRader.Y, obj, i, cur.value.p); if (curIndex - lastIndex > 1) { int overIndex = lastIndex + 1; while (overIndex != curIndex) { float lerp = MathHelper.Lerp(lastDepth, curDepth, (curIndex - overIndex) / (curIndex - lastIndex)); SetValueAtIndex(overIndex, lerp, obj, i, cur.value.p); overIndex++; } } else if (curIndex - lastIndex < -1) { int overIndex = lastIndex - 1; while (overIndex != curIndex) { float lerp = MathHelper.Lerp(lastDepth, curDepth, (curIndex - overIndex) / (curIndex - lastIndex)); SetValueAtIndex(overIndex, lerp, obj, i, cur.value.p); overIndex--; } } } lastIndex = curIndex; lastDepth = curDepth; cur = cur.next; } }
private void SetValueAtIndex( int index, float value, IShelterObj obj, int bordIndex, Point bordp ) { if (index < 0 || index >= depthMap.Length) return; if (value < depthMap[index]) { depthMap[index] = value; objMap[index] = obj; objBordIndexMap[index] = new BordPoint( bordIndex, bordp ); } }
public void ApplyShelterObj( Rader rader, IShelterObj obj ) { Matrix worldMatrix = obj.WorldTrans; CircleList<BorderPoint> border = obj.BorderData; CircleListNode<BorderPoint> lastB = border.First.pre; Vector2 pInRader = rader.TranslateToRaderSpace( Vector2.Transform( ConvertHelper.PointToVector2( lastB.value.p ), worldMatrix ) ); int lastIndex = IndexOf( pInRader.X ); float lastDepth = pInRader.Y; CircleListNode<BorderPoint> cur = border.First; for (int i = 0; i < border.Length; i++) { pInRader = rader.TranslateToRaderSpace( Vector2.Transform( ConvertHelper.PointToVector2( cur.value.p ), worldMatrix ) ); int curIndex = IndexOf( pInRader.X ); float curDepth = pInRader.Y; if (pInRader.X >= -1.1f && pInRader.X <= 1.3f) { //this[pInRader.X] = Math.Min( this[pInRader.X], pInRader.Y ); SetValueAtIndex( curIndex, pInRader.Y, obj, i, cur.value.p ); if (curIndex - lastIndex > 1) { int overIndex = lastIndex + 1; while (overIndex != curIndex) { float lerp = MathHelper.Lerp( lastDepth, curDepth, (curIndex - overIndex) / (curIndex - lastIndex) ); SetValueAtIndex( overIndex, lerp, obj, i, cur.value.p ); overIndex++; } } else if (curIndex - lastIndex < -1) { int overIndex = lastIndex - 1; while (overIndex != curIndex) { float lerp = MathHelper.Lerp( lastDepth, curDepth, (curIndex - overIndex) / (curIndex - lastIndex) ); SetValueAtIndex( overIndex, lerp, obj, i, cur.value.p ); overIndex--; } } } lastIndex = curIndex; lastDepth = curDepth; cur = cur.next; } }