From beb9d0f322e7f060afe168359c25065316fd67d8 Mon Sep 17 00:00:00 2001 From: Tungdv Date: Mon, 20 Oct 2025 16:37:08 +0700 Subject: [PATCH] fix: update logic worktrace --- .../Scripts/Managers/A3DTerrain2.cs | 14 +- .../Scripts/Managers/EC_OrnamentMan.cs | 149 +++++++++--------- Assets/Scripts/Move/EC_CDR.cs | 38 ++--- 3 files changed, 108 insertions(+), 93 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Managers/A3DTerrain2.cs b/Assets/PerfectWorld/Scripts/Managers/A3DTerrain2.cs index f802c783da..745dcd8a0c 100644 --- a/Assets/PerfectWorld/Scripts/Managers/A3DTerrain2.cs +++ b/Assets/PerfectWorld/Scripts/Managers/A3DTerrain2.cs @@ -1,6 +1,9 @@ using BrewMonster.Scripts.Player; using CSNetwork.GPDataType; +using NUnit.Framework; +using System.Collections.Generic; using System.Linq; +using UnityEngine; using ARectF = BrewMonster.Scripts.ARect; using ARectI = BrewMonster.Scripts.ARect; using BlockArray = System.Collections.Generic.List; @@ -240,6 +243,7 @@ namespace BrewMonster.Scripts.World public int m_iNumAllBlockRow = 0; // Row number of all blocks public int m_iNumAllBlockCol = 0; // Column number of all blocks public bool m_bVertexLight = false; // true, force to use vertex light rather than lightmap + public List m_lstMesh; // Check lightmap or vertex-light is used public bool UseLightmapTech() { return !m_bVertexLight; } @@ -249,8 +253,16 @@ namespace BrewMonster.Scripts.World // Get grid faces of specified area public bool GetFacesOfArea(A3DVECTOR3 vCenter, int iGridWid, int iGridLen, ref A3DVECTOR3[] pVertBuf, ref WORD[] pIdxBuf) { - if (m_pCurActBlocks.rcArea.IsEmpty()) + //if (m_pCurActBlocks.rcArea.IsEmpty()) + // return false; + if(m_lstMesh == null || m_lstMesh.Count == 0) + { return false; + } + + float halfW = (iGridWid * m_fGridSize) / 2f; + float halfL = (iGridLen * m_fGridSize) / 2f; + Bounds area = new Bounds(EC_Utility.ToVector3(vCenter), new Vector3(halfW * 2, 1000f, halfL * 2)); float fInvGridSize = 1.0f / m_fGridSize; diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_OrnamentMan.cs b/Assets/PerfectWorld/Scripts/Managers/EC_OrnamentMan.cs index e1cc6580a4..8315be2ff5 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_OrnamentMan.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_OrnamentMan.cs @@ -10,87 +10,88 @@ namespace BrewMonster.Scripts.Ornament public virtual bool TraceWithBrush(ref BrushTraceInfo pInfo) { bool bCollide = false; + //TO DO: fix later //save original result - bool bStartSolid = pInfo.bStartSolid; // Collide something at start point - bool bAllSolid = pInfo.bAllSolid; // All in something - int iClipPlane = pInfo.iClipPlane; // Clip plane's index - float fFraction = 100.0f; // Fraction - A3DVECTOR3 vNormal = pInfo.ClipPlane.GetNormal(); //clip plane normal - float fDist = pInfo.ClipPlane.GetDist(); //clip plane dist + //bool bStartSolid = pInfo.bStartSolid; // Collide something at start point + //bool bAllSolid = pInfo.bAllSolid; // All in something + //int iClipPlane = pInfo.iClipPlane; // Clip plane's index + //float fFraction = 100.0f; // Fraction + //A3DVECTOR3 vNormal = pInfo.ClipPlane.GetNormal(); //clip plane normal + //float fDist = pInfo.ClipPlane.GetDist(); //clip plane dist - if (m_pBrushMan != null && m_pBrushMan.Trace(pInfo) - && (pInfo.fFraction < fFraction)) - { - fFraction = pInfo.fFraction; - bAllSolid = pInfo.bAllSolid; - bStartSolid = pInfo.bStartSolid; - iClipPlane = pInfo.iClipPlane; - vNormal = pInfo.ClipPlane.GetNormal(); - fDist = pInfo.ClipPlane.GetDist(); - bCollide = true; - } + //if (m_pBrushMan != null && m_pBrushMan.Trace(pInfo) + // && (pInfo.fFraction < fFraction)) + //{ + // fFraction = pInfo.fFraction; + // bAllSolid = pInfo.bAllSolid; + // bStartSolid = pInfo.bStartSolid; + // iClipPlane = pInfo.iClipPlane; + // vNormal = pInfo.ClipPlane.GetNormal(); + // fDist = pInfo.ClipPlane.GetDist(); + // bCollide = true; + //} - HomeOnmtTable::iterator it1 = m_HomeOrnamentTab.begin(); - for (; it1 != m_HomeOrnamentTab.end(); ++it1) - { - CECHomeOrnament* pHomeOrnament = *it1.value(); - if (!pHomeOrnament.IsLoaded()) - continue; + //HomeOnmtTable::iterator it1 = m_HomeOrnamentTab.begin(); + //for (; it1 != m_HomeOrnamentTab.end(); ++it1) + //{ + // CECHomeOrnament* pHomeOrnament = *it1.value(); + // if (!pHomeOrnament.IsLoaded()) + // continue; - CELBuildingWithBrush* pBuildingWithBrush = pHomeOrnament.GetBuildingWithBrush(); - if (pBuildingWithBrush && pBuildingWithBrush.TraceWithBrush(pInfo) && (pInfo.fFraction < fFraction)) - { - fFraction = pInfo.fFraction; - bAllSolid = pInfo.bAllSolid; - bStartSolid = pInfo.bStartSolid; - iClipPlane = pInfo.iClipPlane; - vNormal = pInfo.ClipPlane.GetNormal(); - fDist = pInfo.ClipPlane.GetDist(); - bCollide = true; - } - } + // CELBuildingWithBrush* pBuildingWithBrush = pHomeOrnament.GetBuildingWithBrush(); + // if (pBuildingWithBrush && pBuildingWithBrush.TraceWithBrush(pInfo) && (pInfo.fFraction < fFraction)) + // { + // fFraction = pInfo.fFraction; + // bAllSolid = pInfo.bAllSolid; + // bStartSolid = pInfo.bStartSolid; + // iClipPlane = pInfo.iClipPlane; + // vNormal = pInfo.ClipPlane.GetNormal(); + // fDist = pInfo.ClipPlane.GetDist(); + // bCollide = true; + // } + //} - // now see if collide with forest - CELForest* pForest = g_pGame.GetGameRun().GetWorld().GetForest(); - if ((fFraction > 0.0f) && pForest - && pForest.TraceWithBrush(pInfo) - && (pInfo.fFraction < fFraction)) - { - fFraction = pInfo.fFraction; - bAllSolid = pInfo.bAllSolid; - bStartSolid = pInfo.bStartSolid; - iClipPlane = pInfo.iClipPlane; - vNormal = pInfo.ClipPlane.GetNormal(); - fDist = pInfo.ClipPlane.GetDist(); - bCollide = true; - } + //// now see if collide with forest + //CELForest* pForest = g_pGame.GetGameRun().GetWorld().GetForest(); + //if ((fFraction > 0.0f) && pForest + // && pForest.TraceWithBrush(pInfo) + // && (pInfo.fFraction < fFraction)) + //{ + // fFraction = pInfo.fFraction; + // bAllSolid = pInfo.bAllSolid; + // bStartSolid = pInfo.bStartSolid; + // iClipPlane = pInfo.iClipPlane; + // vNormal = pInfo.ClipPlane.GetNormal(); + // fDist = pInfo.ClipPlane.GetDist(); + // bCollide = true; + //} - // now see if collide with dynamic scene building - ECModelTable::iterator it = m_ECModelTab.begin(); - for (; it != m_ECModelTab.end(); ++it) - { - ECMODELNODE* pNode = *it.value(); - if ((fFraction > 0.0f) && pNode - && pNode.TraceWithBrush(pInfo) - && (pInfo.fFraction < fFraction)) - { - fFraction = pInfo.fFraction; - bAllSolid = pInfo.bAllSolid; - bStartSolid = pInfo.bStartSolid; - iClipPlane = pInfo.iClipPlane; - vNormal = pInfo.ClipPlane.GetNormal(); - fDist = pInfo.ClipPlane.GetDist(); - bCollide = true; - } - } + //// now see if collide with dynamic scene building + //ECModelTable::iterator it = m_ECModelTab.begin(); + //for (; it != m_ECModelTab.end(); ++it) + //{ + // ECMODELNODE* pNode = *it.value(); + // if ((fFraction > 0.0f) && pNode + // && pNode.TraceWithBrush(pInfo) + // && (pInfo.fFraction < fFraction)) + // { + // fFraction = pInfo.fFraction; + // bAllSolid = pInfo.bAllSolid; + // bStartSolid = pInfo.bStartSolid; + // iClipPlane = pInfo.iClipPlane; + // vNormal = pInfo.ClipPlane.GetNormal(); + // fDist = pInfo.ClipPlane.GetDist(); + // bCollide = true; + // } + //} - //set back - pInfo.fFraction = fFraction; - pInfo.bStartSolid = bStartSolid; - pInfo.bAllSolid = bAllSolid; - pInfo.iClipPlane = iClipPlane; - pInfo.ClipPlane.SetNormal(vNormal); - pInfo.ClipPlane.SetD(fDist); + ////set back + //pInfo.fFraction = fFraction; + //pInfo.bStartSolid = bStartSolid; + //pInfo.bAllSolid = bAllSolid; + //pInfo.iClipPlane = iClipPlane; + //pInfo.ClipPlane.SetNormal(vNormal); + //pInfo.ClipPlane.SetD(fDist); return bCollide; } diff --git a/Assets/Scripts/Move/EC_CDR.cs b/Assets/Scripts/Move/EC_CDR.cs index 898bc960bc..b1991728a5 100644 --- a/Assets/Scripts/Move/EC_CDR.cs +++ b/Assets/Scripts/Move/EC_CDR.cs @@ -502,28 +502,30 @@ namespace BrewMonster.Scripts public static bool AABBCollideWithBrush(ref BrushTraceInfo pInfo) { - CECWorld pWorld = CECWorld.Instance; //g_pGame.GetGameRun().GetWorld(); + //TO DO: fix later + return false; + //CECWorld pWorld = CECWorld.Instance; //g_pGame.GetGameRun().GetWorld(); - CECOrnamentMan pOrnMan = pWorld.GetOrnamentMan(); - bool bBrush = pOrnMan.TraceWithBrush(ref pInfo); + //CECOrnamentMan pOrnMan = pWorld.GetOrnamentMan(); + //bool bBrush = pOrnMan.TraceWithBrush(ref pInfo); - BrushTraceInfo info = pInfo; - CECMatterMan pMatterMan = pWorld.GetMatterMan(); - if (pMatterMan.TraceWithBrush(&info) && info.fFraction < pInfo.fFraction) - { - *pInfo = info; - bBrush = true; - } + //BrushTraceInfo info = pInfo; + //CECMatterMan pMatterMan = pWorld.GetMatterMan(); + //if (pMatterMan.TraceWithBrush(ref info) && info.fFraction < pInfo.fFraction) + //{ + // pInfo = info; + // bBrush = true; + //} - info = *pInfo; - CECNPCMan* pNPCMan = pWorld.GetNPCMan(); - if (pNPCMan.TraceWithBrush(&info) && info.fFraction < pInfo.fFraction) - { - *pInfo = info; - bBrush = true; - } + //info = pInfo; + //CECNPCMan pNPCMan = pWorld.GetNPCMan(); + //if (pNPCMan.TraceWithBrush(ref info) && info.fFraction < pInfo.fFraction) + //{ + // pInfo = info; + // bBrush = true; + //} - return bBrush; + //return bBrush; } } public struct OtherPlayer_Move_Info