コード例 #1
0
        private QuadNode InsertObjectToNode(QuadNode node, IQuadObject quadObject)
        {
            if (!node.Bounds.Contains(quadObject.Bounds))
            {
                CoreLogger.Error(LOG_TAG, "QuadTree::InsertObjectToNode->Object's bounds is not fit within node bounds");
                return(null);
            }

            if (node.IsLeaf && node.Depth < m_MaxDepth && node.ObjectCount >= m_NodeSplitThreshold)
            {
                SplitNode(node);
                ResetNodeObjects(node);
            }

            if (!node.IsLeaf)
            {
                QuadNode[] childNodes = node.ChildNodes;
                foreach (var childNode in childNodes)
                {
                    if (childNode.Bounds.Contains(quadObject.Bounds))
                    {
                        return(InsertObjectToNode(childNode, quadObject));
                    }
                }
            }

            node.InsertObject(quadObject);
            m_ObjectToNodeDic[quadObject] = node;

            return(node);
        }
コード例 #2
0
        /// <summary>
        /// 更新指定的对象(一般情况下,由于对象发生了位置变化造成AABB变化后需要更新)
        /// </summary>
        /// <param name="quadObject"></param>
        public void UpdateObject(IQuadObject quadObject)
        {
            if (m_ObjectToNodeDic.TryGetValue(quadObject, out var node))
            {
                RemoveObjectFromNode(node, quadObject);

                QuadNode targetNode = node;
                while (targetNode != null)
                {
                    if (targetNode.Bounds.Contains(quadObject.Bounds))
                    {
                        break;
                    }
                    targetNode = targetNode.ParentNode;
                }
                if (targetNode != null)
                {
                    targetNode = InsertObjectToNode(targetNode, quadObject);

                    if (targetNode != node)
                    {
                        MergeNode(node);
                    }
                }
                else
                {
                    CoreLogger.Error(QuadTree.LOG_TAG, "the object hasn't been added to tree");
                }
            }
            else
            {
                CoreLogger.Error(QuadTree.LOG_TAG, "the object hasn't been added to tree");
            }
        }
コード例 #3
0
ファイル: Logger.cs プロジェクト: bootzin/BootEngine
 public static void CoreError(object message, Exception ex = null)
 {
     if (message is string)
     {
         CoreLogger.Error(ex, message as string);
     }
     else
     {
         CoreLogger.Error(ex, message.ToString());
     }
 }
コード例 #4
0
        public void Release(T element)
        {
#if DEBUG
            if (m_Stack.Contains(element))
            {
                CoreLogger.Error("ObjectPool", "the element has been released");
                return;
            }
#endif

            m_ReleaseItemFunc?.Invoke(element);
            m_Stack.Push(element);
        }
コード例 #5
0
        public void Release(T element)
        {
#if DEBUG
            if (m_Stack.Contains(element))
            {
                CoreLogger.Error("ObjectPool", "GenericObjectPool::Release->The element has been push into pool!");
                return;
            }
#endif

            m_OnRelease?.Invoke(element);
            m_Stack.Push(element);
        }
コード例 #6
0
        public void Release(T element)
        {
            if (element != null)
            {
                element.OnRelease();

#if DEBUG
                if (m_Stack.Contains(element))
                {
                    CoreLogger.Error("ObjectPool", "ItemObjectPool::Release->The element has been push into pool!");
                    return;
                }
#endif
                m_Stack.Push(element);
            }
        }
コード例 #7
0
        public static Type GetGenericType(string genericTypeFullName, params string[] paramTypeFullNames)
        {
            if (string.IsNullOrEmpty(genericTypeFullName) || paramTypeFullNames == null || paramTypeFullNames.Length == 0)
            {
                CoreLogger.Error(LOG_TAG, "Arg is Null");
                return(null);
            }

            Type genericType = GetTypeByFullName(genericTypeFullName);

            if (genericType == null)
            {
                CoreLogger.Error(LOG_TAG, $"Type Not Found.Type = {genericTypeFullName}");
                return(null);
            }

            Type[] types = new Type[paramTypeFullNames.Length];
            for (int i = 0; i < paramTypeFullNames.Length; i++)
            {
                string typeStr = paramTypeFullNames[i];
                if (string.IsNullOrEmpty(typeStr))
                {
                    CoreLogger.Error(LOG_TAG, "Param Type Is NUll");
                    return(null);
                }
                Type t = GetTypeByFullName(paramTypeFullNames[i]);
                if (t == null)
                {
                    CoreLogger.Error(LOG_TAG, $"Param Type Not Found.Type = {paramTypeFullNames[i]}");
                    return(null);
                }
                types[i] = t;
            }

            Type result = genericType.MakeGenericType(types);

            return(result);
        }