private void GatherEnvItemsInBoxes() { var work = Interlocked.Exchange(ref m_cubeBlocksPending, m_cubeBlocksToWork); m_cubeBlocksToWork = work; int itemsVisited = 0; int blocksVisited = 0; ProfilerShort.Begin("PlanetEnvironment::GatherItemsInSlimBlocks()"); foreach (var grid in work.Values) { for (int blockIndex = 0; blockIndex < grid.Count; ++blockIndex) { BoundingBoxD blockAabb = grid[blockIndex]; MyGamePruningStructure.GetAllVoxelMapsInBox(ref blockAabb, m_tmpVoxelList); blocksVisited++; for (int i = 0; i < m_tmpVoxelList.Count; ++i) { var p = m_tmpVoxelList[i] as MyPlanet; if (p == null) { continue; } p.Hierarchy.QueryAABB(ref blockAabb, m_tmpEntityList); for (int j = 0; j < m_tmpEntityList.Count; ++j) { var sector = m_tmpEntityList[j] as MyEnvironmentSector; if (sector == null) { return; } var bb = blockAabb; sector.GetItemsInAabb(ref bb, m_itemsToDisable.GetOrAddList(sector)); if (sector.DataView != null && sector.DataView.Items != null) { itemsVisited += sector.DataView.Items.Count; } } m_tmpEntityList.Clear(); } m_tmpVoxelList.Clear(); } } ProfilerShort.End(); //Debug.Print("Processed {0} blocks with {1} items", blocksVisited, itemsVisited); work.Clear(); }
private void DrawWatch(MyListDictionary <MemberInfo, MemberInfo> watch) { PlotHistory(); if (watch == null) { return; } List <object> log = new CacheList <object>(watch.Values.Count); StringBuilder sb = new StringBuilder(); Vector2 pos = new Vector2(100, 50);// m_counter * 0.2f); int i = -1; foreach (var list in watch.Values) { i++; if (i < SelectedMember) { continue; } object currentInstance = SelectedEntity; foreach (var member in list) { sb.Append("."); sb.Append(member.Name); currentInstance = member.GetValue(currentInstance); } sb.Append(":"); sb.Append(currentInstance.ToString()); MyRenderProxy.DebugDrawText2D(pos, sb.ToString(), m_toPlot.Contains(i) ? m_colors[i] : Color.White, 0.55f); pos.Y += 12; sb.Clear(); log.Add(currentInstance); } pos.X = 90; foreach (var toPlot in m_toPlot) { int idx = (toPlot - SelectedMember); if (idx < 0) { continue; } pos.Y = 50 + idx * 12; MyRenderProxy.DebugDrawText2D(pos, "*", m_colors[toPlot], 0.55f); } m_history.Add(log); if (m_history.Count >= MAX_HISTORY) { m_history.RemoveAtFast(m_frame); } m_frame++; m_frame %= MAX_HISTORY; }
internal void Clear() { if (m_VBs == null) { m_VBs = new Buffer[8]; m_strides = new int[8]; m_CBs = new Buffer[8]; m_bindings = new Dictionary <int, MyBinding>(); m_slotToBindingKeys = new MyListDictionary <int, int>(); m_srvBindings = new MyListDictionary <int, int>(); m_RTVs = new RenderTargetView[8]; m_SRVs = new ShaderResourceView[8]; m_constantsVersion = new Dictionary <Buffer, int>(); m_constantBindings = new Dictionary <MyStageBinding, Buffer>(MyStageBinding.Comparer); m_srvTableBindings = new Dictionary <MyStageSrvBinding, int>(MyStageSrvBinding.Comparer); m_srvBindings1 = new List <MyStageSrvBinding>(); } m_IB = null; m_inputLayout = null; m_ps = null; m_vs = null; m_gs = null; m_RS = null; m_BS = null; m_DS = null; m_stencilRef = 0; Array.Clear(m_VBs, 0, m_VBs.Length); Array.Clear(m_CBs, 0, m_CBs.Length); m_bindings.Clear(); m_slotToBindingKeys.Clear(); m_srvBindings.Clear(); m_constantsVersion.Clear(); m_constantBindings.Clear(); m_srvTableBindings.Clear(); m_srvBindings1.SetSize(0); }
private void RenderCallback() { if (m_form.propertyGrid1.SelectedObject != SelectedEntity) { m_form.propertyGrid1.SelectedObject = SelectedEntity; } if (!m_showWatch) { return; } MyListDictionary <MemberInfo, MemberInfo> watch = null; m_watch.TryGetValue(m_selectedType, out watch); if (watch == null) { return; } int neededRows = Math.Max(0, watch.Values.Count - m_form.Watch.Rows.Count); if (neededRows != 0) { m_form.Watch.Rows.Add(neededRows); } int idx = 0; foreach (var list in watch.Values) { object currentInstance = SelectedEntity; MemberInfo currentMember = null; foreach (var member in list) { currentInstance = member.GetValue(currentInstance); currentMember = member; } (m_form.Watch.Rows[idx].Cells[0] as DataGridViewTextBoxCell).Value = currentMember.Name; (m_form.Watch.Rows[idx].Cells[1] as DataGridViewTextBoxCell).Value = currentInstance.ToString(); idx++; } }
public override void Draw() { base.Draw(); if (SelectedEntity == null) { return; } MyListDictionary <MemberInfo, MemberInfo> watch = null; m_watch.TryGetValue(m_selectedType, out watch); if (m_showWatch) { DrawWatch(watch); return; } StringBuilder sb = new StringBuilder(SelectedEntity.GetType().Name); Type currentType = m_selectedType; m_currentInstance = SelectedEntity; foreach (var member in m_currentPath) { sb.Append("."); sb.Append(member.Name); m_currentInstance = member.GetValue(m_currentInstance); currentType = m_currentInstance.GetType(); } if (currentType != m_lastType) { m_lastType = currentType; m_members.Clear(); MemberInfo[] members = currentType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var member in members) { if (member.DeclaringType == currentType) { m_members.Add(member); } } //m_members.AddArray(members); members = currentType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var member in members) { if (member.DeclaringType == currentType) { m_members.Add(member); } } m_members.Sort((x, y) => string.Compare(x.Name, y.Name)); //m_members.AddArray(members); } Vector2 pos = new Vector2(100, 50);// m_counter * 0.2f); MyRenderProxy.DebugDrawText2D(pos, sb.ToString(), Color.White, 0.65f); pos.Y += 20; for (int i = SelectedMember; i < m_members.Count; i++) { var info = m_members[i]; object value = info.GetValue(m_currentInstance); var text = value != null?value.ToString() : "null"; text = text.Replace("\n", ""); MyRenderProxy.DebugDrawText2D(pos, info.Name + " : " + text, (watch != null && watch.GetList(info) != null) ? Color.Green : Color.White, 0.55f); pos.Y += 12; } }
public override bool HandleInput() { var handled = base.HandleInput(); if (handled) { return(true); } if (MyInput.Static.IsKeyPress(MyKeys.OemTilde)) { var info = m_members.Count > SelectedMember ? m_members[SelectedMember] : null; if (MyInput.Static.IsNewKeyPressed(MyKeys.OemPeriod)) { if (m_currentPath.Count > 0 && m_currentPath[m_currentPath.Count - 1] == info) { return(true); } var obj = info.GetValue(m_currentInstance); if (obj != null && !obj.GetType().IsPrimitive&& obj.GetType().GetFields().Length + obj.GetType().GetProperties().Length > 0) { m_currentPath.Add(info); } m_counter = 0; return(true); } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemComma)) { if (m_currentPath.Count > 0) { m_currentPath.RemoveAt(m_currentPath.Count - 1); m_counter = 0; } return(true); } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemQuestion)) { if (m_showWatch) { if (!m_toPlot.Add(SelectedMember)) { m_toPlot.Remove(SelectedMember); } } else { MyListDictionary <MemberInfo, MemberInfo> watch = null; if (!m_watch.TryGetValue(m_selectedType, out watch)) { watch = m_watch[m_selectedType] = new MyListDictionary <MemberInfo, MemberInfo>(); } var lst = watch.GetList(info); if (lst != null) { watch.Remove(info); return(true); } lst = watch.GetOrAddList(info); lst.AddList(m_currentPath); lst.Add(info); } return(true); } else if (MyInput.Static.IsNewKeyPressed(MyKeys.M)) { m_showWatch = !m_showWatch; } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemPlus)) { m_scale *= 2; } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemMinus)) { m_scale /= 2; } m_counter += VRage.Input.MyInput.Static.PreviousMouseScrollWheelValue() - VRage.Input.MyInput.Static.MouseScrollWheelValue(); m_counter = (long)MyMath.Clamp(m_counter, 0, m_members.Count / 0.002f); } return(handled); }
private void GatherEnvItemsInBoxes() { var work = Interlocked.Exchange(ref m_cubeBlocksPending, m_cubeBlocksToWork); m_cubeBlocksToWork = work; int itemsVisited = 0; int blocksVisited = 0; ProfilerShort.Begin("PlanetEnvironment::GatherItemsInSlimBlocks()"); foreach (var grid in work.Values) { for (int blockIndex = 0; blockIndex < grid.Count; ++blockIndex) { BoundingBoxD blockAabb = grid[blockIndex]; MyGamePruningStructure.GetAllVoxelMapsInBox(ref blockAabb, m_tmpVoxelList); blocksVisited++; for (int i = 0; i < m_tmpVoxelList.Count; ++i) { var p = m_tmpVoxelList[i] as MyPlanet; if (p == null) continue; p.Hierarchy.QueryAABB(ref blockAabb, m_tmpEntityList); for (int j = 0; j < m_tmpEntityList.Count; ++j) { var sector = m_tmpEntityList[j] as MyEnvironmentSector; if (sector == null) return; var bb = blockAabb; sector.GetItemsInAabb(ref bb, m_itemsToDisable.GetOrAddList(sector)); if (sector.DataView != null && sector.DataView.Items != null) itemsVisited += sector.DataView.Items.Count; } m_tmpEntityList.Clear(); } m_tmpVoxelList.Clear(); } } ProfilerShort.End(); //Debug.Print("Processed {0} blocks with {1} items", blocksVisited, itemsVisited); work.Clear(); }
private void DrawWatch(MyListDictionary<MemberInfo, MemberInfo> watch) { PlotHistory(); if (watch == null) return; List<object> log = new CacheList<object>(watch.Values.Count); StringBuilder sb = new StringBuilder(); Vector2 pos = new Vector2(100, 50);// m_counter * 0.2f); int i = -1; foreach (var list in watch.Values) { i++; if(i < SelectedMember) continue; object currentInstance = SelectedEntity; foreach (var member in list) { sb.Append("."); sb.Append(member.Name); currentInstance = member.GetValue(currentInstance); } sb.Append(":"); sb.Append(currentInstance.ToString()); MyRenderProxy.DebugDrawText2D(pos, sb.ToString(), m_toPlot.Contains(i) ? m_colors[i] : Color.White, 0.55f); pos.Y += 12; sb.Clear(); log.Add(currentInstance); } pos.X = 90; foreach (var toPlot in m_toPlot) { int idx = (toPlot - SelectedMember); if (idx < 0) continue; pos.Y = 50 + idx * 12; MyRenderProxy.DebugDrawText2D(pos, "*", m_colors[toPlot], 0.55f); } m_history.Add(log); if(m_history.Count >= MAX_HISTORY) m_history.RemoveAtFast(m_frame); m_frame++; m_frame %= MAX_HISTORY; }
public override bool HandleInput() { var handled = base.HandleInput(); if (handled) return true; if (MyInput.Static.IsKeyPress(MyKeys.OemTilde)) { var info = m_members.Count > SelectedMember ? m_members[SelectedMember] : null; if (MyInput.Static.IsNewKeyPressed(MyKeys.OemPeriod)) { if (m_currentPath.Count > 0 && m_currentPath[m_currentPath.Count - 1] == info) return true; var obj = info.GetValue(m_currentInstance); if (obj != null && !obj.GetType().IsPrimitive && obj.GetType().GetFields().Length + obj.GetType().GetProperties().Length > 0) { m_currentPath.Add(info); } m_counter = 0; return true; } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemComma)) { if (m_currentPath.Count > 0) { m_currentPath.RemoveAt(m_currentPath.Count - 1); m_counter = 0; } return true; } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemQuestion)) { if (m_showWatch) { if (!m_toPlot.Add(SelectedMember)) m_toPlot.Remove(SelectedMember); } else { MyListDictionary<MemberInfo, MemberInfo> watch = null; if (!m_watch.TryGetValue(m_selectedType, out watch)) watch = m_watch[m_selectedType] = new MyListDictionary<MemberInfo, MemberInfo>(); var lst = watch.GetList(info); if (lst != null) { watch.Remove(info); return true; } lst = watch.GetOrAddList(info); lst.AddList(m_currentPath); lst.Add(info); } return true; } else if (MyInput.Static.IsNewKeyPressed(MyKeys.M)) { m_showWatch = !m_showWatch; } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemPlus)) m_scale *= 2; else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemMinus)) m_scale /= 2; m_counter += VRage.Input.MyInput.Static.PreviousMouseScrollWheelValue() - VRage.Input.MyInput.Static.MouseScrollWheelValue(); m_counter = (long)MyMath.Clamp(m_counter, 0, m_members.Count / 0.002f); } return handled; }