public Actor.GActor PickActorWithFilter(out VHitResult hitResult, ref Bricks.PhysicsCore.PhyQueryFilterData queryFilterData, Graphics.CGfxCamera camera, int x, int y, float length = 1000.0f) { if (camera == null) { camera = CEngine.Instance.GameInstance?.GameCamera; } if (camera == null) { hitResult = VHitResult.Default; return(null); } var pickDir = new Vector3(); if (camera.GetPickRay(ref pickDir, x, y, 0, 0) == false) { hitResult = VHitResult.Default; return(null); } var start = camera.CameraData.Position; var end = camera.CameraData.Position + pickDir * length; var tmp = VHitResult.Default; if (this.LineCheckWithFilter(ref start, ref end, ref queryFilterData, ref tmp) == false) { hitResult = VHitResult.Default; return(null); } hitResult = tmp; Actor.GActor outActor = null; GetHitActorByPhysics(ref hitResult, ref outActor); return(outActor); }
public void OnCheckVisible(CCommandList cmd, GSceneGraph scene, CGfxCamera camera, CheckVisibleParam param) { if (HostSet == null) { throw new InvalidOperationException(""); } var bitSet = HostSet.PvsData[PvsIndex]; if (scene.PVSActors != null && scene.PVSActors.Length == bitSet.BitCount) { for (int i = 0; i < bitSet.BitCount; i++) { if (!bitSet.IsBit(i)) { continue; } Actor.GActor actor = scene.PVSActors[i]; if (actor.NeedCheckVisible(param) == false) { continue; } if (param.FrustumCulling && actor.CheckContain(camera.CullingFrustum, true) == CGfxCamera.CFrustum.CONTAIN_TYPE.CONTAIN_TEST_OUTER) { continue; } actor.OnCheckVisible(cmd, scene, camera, param); } } }
public float GetPointLightEffectFactor(Actor.GActor actor) { float dist; if (BoundingBox.Intersects(ref actor.Placement.ActorAABB, ref LightSphere, out dist) == false) { return(-1); } return(dist); }
partial void GetHitActorByPhysics(ref SceneGraph.VHitResult hitResult, ref Actor.GActor outActor) { if (hitResult.ExtData == IntPtr.Zero) { return; } var handle = System.Runtime.InteropServices.GCHandle.FromIntPtr(hitResult.ExtData); var phyActor = handle.Target as Bricks.PhysicsCore.CPhyActor; if (phyActor == null) { return; } outActor = phyActor.HostActor; }
public void SetMeshAffectLights(Graphics.View.CGfxSceneView view, Actor.GActor actor) { actor.VisitChildComponents(mOnVisitComponent_SetPointLights, view); }
//public static Profiler.TimeScope ScopeAffectLightsStatic = Profiler.TimeScopeManager.GetTimeScope(typeof(GSceneGraph), "GetAffectLights.Static", Profiler.TimeScope.EProfileFlag.Windows); //public static Profiler.TimeScope ScopeAffectLightsDynamic = Profiler.TimeScopeManager.GetTimeScope(typeof(GSceneGraph), "GetAffectLights.Dynamic", Profiler.TimeScope.EProfileFlag.Windows); //public static Profiler.TimeScope ScopeAffectLightsSetCBuffer = Profiler.TimeScopeManager.GetTimeScope(typeof(GSceneGraph), "GetAffectLights.CBuffer", Profiler.TimeScope.EProfileFlag.Windows); public void GetAffectLights(Graphics.View.CGfxSceneView view, Actor.GActor actor, bool bSet2CBuffer) { if (view == null) { return; } //ScopeAffectLightsStatic.Begin(); var staticlights = actor.StaticLights; if (actor.StaticObject) { if (actor.PointLightsSerialId != actor.Scene.PointLightsSerialId) { staticlights.Clear(); for (int i = 0; i < PointLights.Count; i++) { if (PointLights[i] == null) { continue; } if (PointLights[i].Host.StaticObject == false) { continue; } float factor = PointLights[i].GetPointLightEffectFactor(actor); if (factor < 0) { continue; } TryAddLight(staticlights, PointLights[i], factor); } actor.PointLightsSerialId = actor.Scene.PointLightsSerialId; } } else { staticlights.Clear(); } var effectLights = actor.AffectLights; effectLights.Clear(); if (staticlights.Count > 0) { //effectLights.AddRange(staticlights);//不能这样操作,查看List源代码,这里会有一次new T[]的操作,导致GC,Add因为Capacity足够反而不会 for (int i = 0; i < staticlights.Count; i++) { effectLights.Add(staticlights[i]); } } //ScopeAffectLightsStatic.End(); if (actor.StaticObject) { //ScopeAffectLightsStatic.Begin(); for (int i = 0; i < DynPointLights.Count; i++) { if (DynPointLights[i] == null) { continue; } float factor = DynPointLights[i].GetPointLightEffectFactor(actor); if (factor < 0) { continue; } TryAddLight(effectLights, DynPointLights[i], factor); } //ScopeAffectLightsStatic.End(); } else { //ScopeAffectLightsDynamic.Begin(); for (int i = 0; i < PointLights.Count; i++) { if (PointLights[i] == null) { continue; } float factor = PointLights[i].GetPointLightEffectFactor(actor); if (factor < 0) { continue; } TryAddLight(effectLights, PointLights[i], factor); } //ScopeAffectLightsDynamic.End(); } if (bSet2CBuffer) { //ScopeAffectLightsSetCBuffer.Begin(); SetMeshAffectLights(view, actor); //ScopeAffectLightsSetCBuffer.End(); } }
public override async System.Threading.Tasks.Task <GComponent> CloneComponent(CRenderContext rc, Actor.GActor host, IComponentContainer hostContainer) { var comp = await base.CloneComponent(rc, host, hostContainer); if (comp == null) { return(null); } comp.HostContainer = host; var container = comp as GComponentsContainer; if (container != null) { for (int i = 0; i < Components.Count; ++i) { var ccp = await Components[i].CloneComponent(rc, host, container); container.AddComponent(ccp); } } return(comp); }