Esempio n. 1
0
        protected void GetHavokPhysicsParams()
        {
            dialogCaptionBar.Description = "Version: " + HavokManaged.ManagedModule.GetVersionInfo();

            // Get settings
            HavokManaged.WorldSetupSettings ws = new HavokManaged.WorldSetupSettings();
            HavokManaged.ManagedModule.GetWorldSetupSettings(ws);
            HavokManaged.WorldRuntimeSettings wr = new HavokManaged.WorldRuntimeSettings();
            HavokManaged.ManagedModule.GetWorldRuntimeSettings(wr);

            _settings = new HavokPhysicsSettingsWrapper();
            _settings.VisionUnitsNoPrompt             = ws.m_havokToVisionScale;
            _settings.StaticGeometryModeNoPrompt      = (HavokPhysicsSettingsWrapper.StaticGeometryMode_e)ws.m_staticGeomMode;
            _settings.MergedStaticWeldingTypeNoPrompt = (HavokPhysicsSettingsWrapper.MergedStaticWeldingType_e)ws.m_mergedStaticWeldingType;
            _settings.BroadphaseSize       = wr.m_broadPhaseSizeAuto ? HavokPhysicsSettingsWrapper.BroadphaseSize_e.BoundAllStaticMeshes : HavokPhysicsSettingsWrapper.BroadphaseSize_e.Manual;
            _settings.BroadphaseSizeManual = wr.m_broadPhaseSizeManual;
            _settings.Gravity = new Vector3F(wr.m_gravityX, wr.m_gravityY, wr.m_gravityZ);
            _settings.ConstrainedBodyCollision = !wr.m_disableConstrainedBodiesCollisions;
            _settings.LegacyCompoundShapes     = wr.m_enableLegacyCompoundShapes;
            _settings.DiskShapeCaching         = wr.m_diskShapeCaching;
            _settings.SolverType = getSolverType(wr.m_solverIterations, wr.m_solverHardness);

            // Update property grid
            PropertyGrid.SelectedObject = _settings;
        }
Esempio n. 2
0
            public void GetObjectData(SerializationInfo info, StreamingContext context)
            {
                try
                {
                    HavokManaged.WorldSetupSettings   ws = new HavokManaged.WorldSetupSettings();
                    HavokManaged.WorldRuntimeSettings wr = new HavokManaged.WorldRuntimeSettings();

                    HavokManaged.ManagedModule.GetWorldSetupSettings(ws);
                    HavokManaged.ManagedModule.GetWorldRuntimeSettings(wr);

                    info.AddValue("HavokToVisionScale", ws.m_havokToVisionScale);
                    info.AddValue("HavokStaticGeomMode", ws.m_staticGeomMode);
                    info.AddValue("HavokMergedStaticWeldingType", ws.m_mergedStaticWeldingType);

                    info.AddValue("HavokAutoBroadPhase", wr.m_broadPhaseSizeAuto);
                    info.AddValue("HavokManualBroadPhaseSize", wr.m_broadPhaseSizeManual);
                    info.AddValue("HavokGravityX", wr.m_gravityX);
                    info.AddValue("HavokGravityY", wr.m_gravityY);
                    info.AddValue("HavokGravityZ", wr.m_gravityZ);
                    info.AddValue("HavokDiskShapeCaching", wr.m_diskShapeCaching);
                    info.AddValue("HavokDisableConstrainedBodiesCollisions", wr.m_disableConstrainedBodiesCollisions);
                    info.AddValue("HavokEnableLegacyCompoundShapes", wr.m_enableLegacyCompoundShapes);
                    foreach (HavokCollisionGroups_e value in Enum.GetValues(typeof(HavokCollisionGroups_e)))
                    {
                        info.AddValue(value.ToString(), wr.m_collisionGroupMasks[(int)value]);
                    }

                    info.AddValue("HavokSolverIterations", wr.m_solverIterations);
                    info.AddValue("HavokSolverHardness", wr.m_solverHardness);
                }
                catch
                {
                }
            }
Esempio n. 3
0
        protected void SetHavokPhysicsParams()
        {
            HavokManaged.WorldSetupSettings ws = new HavokManaged.WorldSetupSettings();
            HavokManaged.ManagedModule.GetWorldSetupSettings(ws);
            HavokManaged.WorldRuntimeSettings wr = new HavokManaged.WorldRuntimeSettings();
            HavokManaged.ManagedModule.GetWorldRuntimeSettings(wr);

            ws.m_havokToVisionScale      = _settings.VisionUnitsNoPrompt;
            ws.m_staticGeomMode          = (int)_settings.StaticGeometryModeNoPrompt;
            ws.m_mergedStaticWeldingType = (int)_settings.MergedStaticWeldingTypeNoPrompt;
            wr.m_broadPhaseSizeAuto      = _settings.BroadphaseSize == HavokPhysicsSettingsWrapper.BroadphaseSize_e.BoundAllStaticMeshes;
            wr.m_broadPhaseSizeManual    = _settings.BroadphaseSizeManual;
            wr.m_gravityX = _settings.Gravity.X;
            wr.m_gravityY = _settings.Gravity.Y;
            wr.m_gravityZ = _settings.Gravity.Z;
            wr.m_disableConstrainedBodiesCollisions = !_settings.ConstrainedBodyCollision;
            wr.m_enableLegacyCompoundShapes         = _settings.LegacyCompoundShapes;
            wr.m_diskShapeCaching = _settings.DiskShapeCaching;
            getSolverIterations(_settings.SolverType, ref wr.m_solverIterations, ref wr.m_solverHardness);

            HavokManaged.ManagedModule.SetWorldSetupSettings(ws, false);
            HavokManaged.ManagedModule.SetWorldRuntimeSettings(wr);

            // Enable saving
            if (EditorManager.Scene != null && EditorManager.Scene.MainLayer != null)
            {
                EditorManager.Scene.MainLayer.Dirty = true;
            }

            // Physics
            HavokManaged.ManagedModule.EnableDebugRendering(_settings.VisualizeDynamicObjects, _settings.VisualizeRagdolls,
                                                            _settings.VisualizeCharacterControllers, _settings.VisualizeTriggerVolumes, _settings.VisualizeBlockerVolumes,
                                                            _settings.VisualizeStaticObjects);
            EditorManager.ActiveView.UpdateView(false);
            PropertyGrid.Refresh();
            toolStripButton_VisDynamics.Checked   = _settings.VisualizeDynamicObjects;
            toolStripButton_VisRagdolls.Checked   = _settings.VisualizeRagdolls;
            toolStripButton_VisController.Checked = _settings.VisualizeCharacterControllers;
            toolStripButton_VisTrigger.Checked    = _settings.VisualizeTriggerVolumes;
            toolStripButton_VisBlocker.Checked    = _settings.VisualizeBlockerVolumes;
            toolStripButton_VisStatic.Checked     = _settings.VisualizeStaticObjects;
        }
            public void GetObjectData(SerializationInfo info, StreamingContext context)
            {
                try
                {
                  HavokManaged.WorldSetupSettings ws = new HavokManaged.WorldSetupSettings();
                  HavokManaged.WorldRuntimeSettings wr = new HavokManaged.WorldRuntimeSettings();

                  HavokManaged.ManagedModule.GetWorldSetupSettings(ws);
                  HavokManaged.ManagedModule.GetWorldRuntimeSettings(wr);

                  info.AddValue("HavokToVisionScale", ws.m_havokToVisionScale);
                  info.AddValue("HavokStaticGeomMode", ws.m_staticGeomMode);
                  info.AddValue("HavokMergedStaticWeldingType", ws.m_mergedStaticWeldingType);

                  info.AddValue("HavokAutoBroadPhase", wr.m_broadPhaseSizeAuto);
                  info.AddValue("HavokManualBroadPhaseSize", wr.m_broadPhaseSizeManual);
                  info.AddValue("HavokGravityX", wr.m_gravityX);
                  info.AddValue("HavokGravityY", wr.m_gravityY);
                  info.AddValue("HavokGravityZ", wr.m_gravityZ);
                  info.AddValue("HavokStaticMeshCaching", wr.m_shapeCaching);
                  info.AddValue("HavokDisableConstrainedBodiesCollisions", wr.m_disableConstrainedBodiesCollisions);
                  info.AddValue("HavokEnableLegacyCompoundShapes", wr.m_enableLegacyCompoundShapes);
                  foreach (HavokCollisionGroups_e value in Enum.GetValues(typeof(HavokCollisionGroups_e)))
                  {
                info.AddValue(value.ToString(), wr.m_collisionGroupMasks[(int)value]);
                  }

                  info.AddValue("HavokSolverIterations", wr.m_solverIterations);
                  info.AddValue("HavokSolverHardness", wr.m_solverHardness);
                }
                catch
                {
                }
            }
            protected HavokPhysicsPanelSettings(SerializationInfo info, StreamingContext context)
            {
                try
                {
                  HavokManaged.WorldSetupSettings ws = new HavokManaged.WorldSetupSettings();
                  HavokManaged.WorldRuntimeSettings wr = new HavokManaged.WorldRuntimeSettings();

                  // Ensure, that all members of settings have proper default values
                  HavokManaged.ManagedModule.ResetWorldSettings();
                  HavokManaged.ManagedModule.GetWorldSetupSettings(ws);
                  HavokManaged.ManagedModule.GetWorldRuntimeSettings(wr);

                  ws.m_havokToVisionScale = (float)info.GetValue("HavokToVisionScale", typeof(float));
                  if (SerializationHelper.HasElement(info, "HavokStaticGeomMode"))
                ws.m_staticGeomMode = (int)info.GetValue("HavokStaticGeomMode", typeof(int));
                  if (SerializationHelper.HasElement(info, "HavokMergedStaticWeldingType"))
                ws.m_mergedStaticWeldingType = (int)info.GetValue("HavokMergedStaticWeldingType", typeof(int));

                  wr.m_broadPhaseSizeAuto = (bool)info.GetValue("HavokAutoBroadPhase", typeof(bool));
                  wr.m_broadPhaseSizeManual = (float)info.GetValue("HavokManualBroadPhaseSize", typeof(float));
                  wr.m_gravityX = (float)info.GetValue("HavokGravityX", typeof(float));
                  wr.m_gravityY = (float)info.GetValue("HavokGravityY", typeof(float));
                  wr.m_gravityZ = (float)info.GetValue("HavokGravityZ", typeof(float));
                  if (SerializationHelper.HasElement(info, "HavokStaticMeshCaching"))
                wr.m_shapeCaching = (bool)info.GetValue("HavokStaticMeshCaching", typeof(bool));

                  if (SerializationHelper.HasElement(info, "HavokDisableConstrainedBodiesCollisions"))
                  {
                wr.m_disableConstrainedBodiesCollisions = (bool)info.GetValue("HavokDisableConstrainedBodiesCollisions", typeof(bool));
                  }
                  if (SerializationHelper.HasElement(info, "HavokEnableLegacyCompoundShapes"))
                  {
                  wr.m_enableLegacyCompoundShapes = (bool)info.GetValue("HavokEnableLegacyCompoundShapes", typeof(bool));
                  }

                  foreach (HavokCollisionGroups_e value in Enum.GetValues(typeof(HavokCollisionGroups_e)))
                  {
                if (SerializationHelper.HasElement(info, value.ToString()))
                  wr.m_collisionGroupMasks[(int)value] = (UInt32)info.GetValue(value.ToString(), typeof(UInt32));
                  }

                  if (SerializationHelper.HasElement(info, "HavokSolverIterations"))
                  wr.m_solverIterations = (int)info.GetValue("HavokSolverIterations", typeof(int));

                  if (SerializationHelper.HasElement(info, "HavokSolverHardness"))
                  wr.m_solverHardness = (int)info.GetValue("HavokSolverHardness", typeof(int));

                  HavokManaged.ManagedModule.SetWorldSetupSettings(ws, true);
                  HavokManaged.ManagedModule.SetWorldRuntimeSettings(wr);
                }
                catch
                {
                }
            }
        protected void SetHavokPhysicsParams()
        {
            HavokManaged.WorldSetupSettings ws = new HavokManaged.WorldSetupSettings();
              HavokManaged.ManagedModule.GetWorldSetupSettings(ws);
              HavokManaged.WorldRuntimeSettings wr = new HavokManaged.WorldRuntimeSettings();
              HavokManaged.ManagedModule.GetWorldRuntimeSettings(wr);

              ws.m_havokToVisionScale = _settings.VisionUnitsNoPrompt;
              ws.m_staticGeomMode = (int)_settings.StaticGeometryModeNoPrompt;
              ws.m_mergedStaticWeldingType = (int)_settings.MergedStaticWeldingTypeNoPrompt;
              wr.m_broadPhaseSizeAuto = _settings.BroadphaseSize == HavokPhysicsSettingsWrapper.BroadphaseSize_e.BoundAllStaticMeshes;
              wr.m_broadPhaseSizeManual = _settings.BroadphaseSizeManual;
              wr.m_gravityX = _settings.Gravity.X;
              wr.m_gravityY = _settings.Gravity.Y;
              wr.m_gravityZ = _settings.Gravity.Z;
              wr.m_disableConstrainedBodiesCollisions = !_settings.ConstrainedBodyCollision;
              wr.m_enableLegacyCompoundShapes = _settings.LegacyCompoundShapes;
              wr.m_shapeCaching = _settings.ShapeCaching;
              getSolverIterations(_settings.SolverType, ref wr.m_solverIterations, ref wr.m_solverHardness);

              HavokManaged.ManagedModule.SetWorldSetupSettings(ws, false);
              HavokManaged.ManagedModule.SetWorldRuntimeSettings(wr);

              // Enable saving
              if (EditorManager.Scene != null && EditorManager.Scene.MainLayer != null)
            EditorManager.Scene.MainLayer.Dirty = true;

              // Physics
              HavokManaged.ManagedModule.EnableDebugRendering(_settings.VisualizeDynamicObjects, _settings.VisualizeRagdolls,
            _settings.VisualizeCharacterControllers, _settings.VisualizeTriggerVolumes, _settings.VisualizeBlockerVolumes,
            _settings.VisualizeStaticObjects);
              EditorManager.ActiveView.UpdateView(false);
              PropertyGrid.Refresh();
              toolStripButton_VisDynamics.Checked = _settings.VisualizeDynamicObjects;
              toolStripButton_VisController.Checked = _settings.VisualizeCharacterControllers;
              toolStripButton_VisTrigger.Checked = _settings.VisualizeTriggerVolumes;
              toolStripButton_VisStatic.Checked = _settings.VisualizeStaticObjects;
        }
        protected void GetHavokPhysicsParams()
        {
            dialogCaptionBar.Description = "Version: " + HavokManaged.ManagedModule.GetVersionInfo();

              // Get settings
              HavokManaged.WorldSetupSettings ws = new HavokManaged.WorldSetupSettings();
              HavokManaged.ManagedModule.GetWorldSetupSettings(ws);
              HavokManaged.WorldRuntimeSettings wr = new HavokManaged.WorldRuntimeSettings();
              HavokManaged.ManagedModule.GetWorldRuntimeSettings(wr);

              _settings = new HavokPhysicsSettingsWrapper();
              _settings.VisionUnitsNoPrompt = ws.m_havokToVisionScale;
              _settings.StaticGeometryModeNoPrompt = (HavokPhysicsSettingsWrapper.StaticGeometryMode_e) ws.m_staticGeomMode;
              _settings.MergedStaticWeldingTypeNoPrompt = (HavokPhysicsSettingsWrapper.MergedStaticWeldingType_e) ws.m_mergedStaticWeldingType;
              _settings.BroadphaseSize = wr.m_broadPhaseSizeAuto ? HavokPhysicsSettingsWrapper.BroadphaseSize_e.BoundAllStaticMeshes : HavokPhysicsSettingsWrapper.BroadphaseSize_e.Manual;
              _settings.BroadphaseSizeManual = wr.m_broadPhaseSizeManual;
              _settings.Gravity = new Vector3F(wr.m_gravityX, wr.m_gravityY, wr.m_gravityZ);
              _settings.ConstrainedBodyCollision = !wr.m_disableConstrainedBodiesCollisions;
              _settings.LegacyCompoundShapes = wr.m_enableLegacyCompoundShapes;
              _settings.ShapeCaching = wr.m_shapeCaching;
              _settings.SolverType = getSolverType(wr.m_solverIterations, wr.m_solverHardness);

              // Update property grid
              PropertyGrid.SelectedObject = _settings;
        }
Esempio n. 8
0
            protected HavokPhysicsPanelSettings(SerializationInfo info, StreamingContext context)
            {
                try
                {
                    HavokManaged.WorldSetupSettings   ws = new HavokManaged.WorldSetupSettings();
                    HavokManaged.WorldRuntimeSettings wr = new HavokManaged.WorldRuntimeSettings();

                    // Ensure, that all members of settings have proper default values
                    HavokManaged.ManagedModule.ResetWorldSettings();
                    HavokManaged.ManagedModule.GetWorldSetupSettings(ws);
                    HavokManaged.ManagedModule.GetWorldRuntimeSettings(wr);

                    ws.m_havokToVisionScale = (float)info.GetValue("HavokToVisionScale", typeof(float));
                    if (SerializationHelper.HasElement(info, "HavokStaticGeomMode"))
                    {
                        ws.m_staticGeomMode = (int)info.GetValue("HavokStaticGeomMode", typeof(int));
                    }
                    if (SerializationHelper.HasElement(info, "HavokMergedStaticWeldingType"))
                    {
                        ws.m_mergedStaticWeldingType = (int)info.GetValue("HavokMergedStaticWeldingType", typeof(int));
                    }

                    wr.m_broadPhaseSizeAuto   = (bool)info.GetValue("HavokAutoBroadPhase", typeof(bool));
                    wr.m_broadPhaseSizeManual = (float)info.GetValue("HavokManualBroadPhaseSize", typeof(float));
                    wr.m_gravityX             = (float)info.GetValue("HavokGravityX", typeof(float));
                    wr.m_gravityY             = (float)info.GetValue("HavokGravityY", typeof(float));
                    wr.m_gravityZ             = (float)info.GetValue("HavokGravityZ", typeof(float));

                    if (SerializationHelper.HasElement(info, "HavokDiskShapeCaching"))
                    {
                        wr.m_diskShapeCaching = (bool)info.GetValue("HavokDiskShapeCaching", typeof(bool));
                    }
                    else if (SerializationHelper.HasElement(info, "HavokStaticMeshCaching")) // old serialization name
                    {
                        wr.m_diskShapeCaching = (bool)info.GetValue("HavokStaticMeshCaching", typeof(bool));
                    }

                    if (SerializationHelper.HasElement(info, "HavokDisableConstrainedBodiesCollisions"))
                    {
                        wr.m_disableConstrainedBodiesCollisions = (bool)info.GetValue("HavokDisableConstrainedBodiesCollisions", typeof(bool));
                    }
                    if (SerializationHelper.HasElement(info, "HavokEnableLegacyCompoundShapes"))
                    {
                        wr.m_enableLegacyCompoundShapes = (bool)info.GetValue("HavokEnableLegacyCompoundShapes", typeof(bool));
                    }

                    foreach (HavokCollisionGroups_e value in Enum.GetValues(typeof(HavokCollisionGroups_e)))
                    {
                        if (SerializationHelper.HasElement(info, value.ToString()))
                        {
                            wr.m_collisionGroupMasks[(int)value] = (UInt32)info.GetValue(value.ToString(), typeof(UInt32));
                        }
                    }

                    if (SerializationHelper.HasElement(info, "HavokSolverIterations"))
                    {
                        wr.m_solverIterations = (int)info.GetValue("HavokSolverIterations", typeof(int));
                    }

                    if (SerializationHelper.HasElement(info, "HavokSolverHardness"))
                    {
                        wr.m_solverHardness = (int)info.GetValue("HavokSolverHardness", typeof(int));
                    }

                    HavokManaged.ManagedModule.SetWorldSetupSettings(ws, true);
                    HavokManaged.ManagedModule.SetWorldRuntimeSettings(wr);
                }
                catch
                {
                }
            }