From 8a837ecf3052fc3ac3c1fe34a0f581f36f000e0c Mon Sep 17 00:00:00 2001 From: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Mon, 19 Jan 2026 21:16:37 -0500 Subject: [PATCH 1/3] Sound checkbox --- TombEditor/Forms/FormSoundSource.Designer.cs | 236 +++++++++--------- TombEditor/Forms/FormSoundSource.cs | 5 + TombEditor/Forms/FormSoundSource.resx | 54 ++-- .../TombEngine/LevelCompilerTombEngine.cs | 3 + TombLib/TombLib/LevelData/IO/Prj2Loader.cs | 1 + TombLib/TombLib/LevelData/IO/Prj2Writer.cs | 1 + .../Instances/SoundSourceInstance.cs | 5 +- 7 files changed, 161 insertions(+), 144 deletions(-) diff --git a/TombEditor/Forms/FormSoundSource.Designer.cs b/TombEditor/Forms/FormSoundSource.Designer.cs index 8142630bbe..4530ae6760 100644 --- a/TombEditor/Forms/FormSoundSource.Designer.cs +++ b/TombEditor/Forms/FormSoundSource.Designer.cs @@ -28,151 +28,156 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.butOK = new DarkUI.Controls.DarkButton(); - this.butCancel = new DarkUI.Controls.DarkButton(); - this.optionPlaySoundFromWadGroupBox = new DarkUI.Controls.DarkGroupBox(); - this.butSearch = new DarkUI.Controls.DarkButton(); - this.tbSearch = new DarkUI.Controls.DarkTextBox(); - this.comboPlayMode = new DarkUI.Controls.DarkComboBox(); - this.darkLabel2 = new DarkUI.Controls.DarkLabel(); - this.butPlaySound = new DarkUI.Controls.DarkButton(); - this.lstSounds = new DarkUI.Controls.DarkListView(); - this.optionPlaySoundFromWadGroupBox.SuspendLayout(); - this.SuspendLayout(); + butOK = new DarkUI.Controls.DarkButton(); + butCancel = new DarkUI.Controls.DarkButton(); + optionPlaySoundFromWadGroupBox = new DarkUI.Controls.DarkGroupBox(); + cbSoundEnabled = new DarkUI.Controls.DarkCheckBox(); + butSearch = new DarkUI.Controls.DarkButton(); + tbSearch = new DarkUI.Controls.DarkTextBox(); + comboPlayMode = new DarkUI.Controls.DarkComboBox(); + darkLabel2 = new DarkUI.Controls.DarkLabel(); + butPlaySound = new DarkUI.Controls.DarkButton(); + lstSounds = new DarkUI.Controls.DarkListView(); + optionPlaySoundFromWadGroupBox.SuspendLayout(); + SuspendLayout(); // // butOK // - this.butOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.butOK.Location = new System.Drawing.Point(306, 535); - this.butOK.Name = "butOK"; - this.butOK.Size = new System.Drawing.Size(80, 23); - this.butOK.TabIndex = 0; - this.butOK.Text = "OK"; - this.butOK.Click += new System.EventHandler(this.butOK_Click); + butOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + butOK.Checked = false; + butOK.Location = new System.Drawing.Point(306, 535); + butOK.Name = "butOK"; + butOK.Size = new System.Drawing.Size(80, 23); + butOK.TabIndex = 0; + butOK.Text = "OK"; + butOK.Click += butOK_Click; // // butCancel // - this.butCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.butCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.butCancel.Location = new System.Drawing.Point(392, 535); - this.butCancel.Name = "butCancel"; - this.butCancel.Size = new System.Drawing.Size(80, 23); - this.butCancel.TabIndex = 1; - this.butCancel.Text = "Cancel"; - this.butCancel.Click += new System.EventHandler(this.butCancel_Click); + butCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + butCancel.Checked = false; + butCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + butCancel.Location = new System.Drawing.Point(392, 535); + butCancel.Name = "butCancel"; + butCancel.Size = new System.Drawing.Size(80, 23); + butCancel.TabIndex = 1; + butCancel.Text = "Cancel"; + butCancel.Click += butCancel_Click; // // optionPlaySoundFromWadGroupBox // - this.optionPlaySoundFromWadGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.optionPlaySoundFromWadGroupBox.Controls.Add(this.butSearch); - this.optionPlaySoundFromWadGroupBox.Controls.Add(this.tbSearch); - this.optionPlaySoundFromWadGroupBox.Controls.Add(this.comboPlayMode); - this.optionPlaySoundFromWadGroupBox.Controls.Add(this.darkLabel2); - this.optionPlaySoundFromWadGroupBox.Controls.Add(this.butPlaySound); - this.optionPlaySoundFromWadGroupBox.Controls.Add(this.lstSounds); - this.optionPlaySoundFromWadGroupBox.Location = new System.Drawing.Point(12, 12); - this.optionPlaySoundFromWadGroupBox.Name = "optionPlaySoundFromWadGroupBox"; - this.optionPlaySoundFromWadGroupBox.Size = new System.Drawing.Size(460, 517); - this.optionPlaySoundFromWadGroupBox.TabIndex = 66; - this.optionPlaySoundFromWadGroupBox.TabStop = false; - this.optionPlaySoundFromWadGroupBox.Text = "Sound to play"; + optionPlaySoundFromWadGroupBox.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + optionPlaySoundFromWadGroupBox.Controls.Add(butSearch); + optionPlaySoundFromWadGroupBox.Controls.Add(tbSearch); + optionPlaySoundFromWadGroupBox.Controls.Add(comboPlayMode); + optionPlaySoundFromWadGroupBox.Controls.Add(darkLabel2); + optionPlaySoundFromWadGroupBox.Controls.Add(butPlaySound); + optionPlaySoundFromWadGroupBox.Controls.Add(lstSounds); + optionPlaySoundFromWadGroupBox.Location = new System.Drawing.Point(12, 12); + optionPlaySoundFromWadGroupBox.Name = "optionPlaySoundFromWadGroupBox"; + optionPlaySoundFromWadGroupBox.Size = new System.Drawing.Size(460, 517); + optionPlaySoundFromWadGroupBox.TabIndex = 66; + optionPlaySoundFromWadGroupBox.TabStop = false; + optionPlaySoundFromWadGroupBox.Text = "Sound to play"; + // + // cbSoundEnabled + // + cbSoundEnabled.AutoSize = true; + cbSoundEnabled.Location = new System.Drawing.Point(12, 541); + cbSoundEnabled.Name = "cbSoundEnabled"; + cbSoundEnabled.Size = new System.Drawing.Size(68, 17); + cbSoundEnabled.TabIndex = 110; + cbSoundEnabled.Text = "Enabled"; // // butSearch // - this.butSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.butSearch.Image = global::TombEditor.Properties.Resources.general_search_16; - this.butSearch.Location = new System.Drawing.Point(428, 21); - this.butSearch.Name = "butSearch"; - this.butSearch.Selectable = false; - this.butSearch.Size = new System.Drawing.Size(24, 23); - this.butSearch.TabIndex = 109; - this.butSearch.Click += new System.EventHandler(this.butSearch_Click); + butSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + butSearch.Checked = false; + butSearch.Image = Properties.Resources.general_search_16; + butSearch.Location = new System.Drawing.Point(428, 21); + butSearch.Name = "butSearch"; + butSearch.Selectable = false; + butSearch.Size = new System.Drawing.Size(24, 23); + butSearch.TabIndex = 109; + butSearch.Click += butSearch_Click; // // tbSearch // - this.tbSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbSearch.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.tbSearch.Location = new System.Drawing.Point(8, 21); - this.tbSearch.Name = "tbSearch"; - this.tbSearch.Size = new System.Drawing.Size(421, 23); - this.tbSearch.TabIndex = 0; - this.tbSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbSearch_KeyDown); + tbSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + tbSearch.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + tbSearch.Location = new System.Drawing.Point(8, 21); + tbSearch.Name = "tbSearch"; + tbSearch.Size = new System.Drawing.Size(421, 23); + tbSearch.TabIndex = 0; + tbSearch.KeyDown += tbSearch_KeyDown; // // comboPlayMode // - this.comboPlayMode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.comboPlayMode.FormattingEnabled = true; - this.comboPlayMode.Items.AddRange(new object[] { - "Always", - "Only when flipmaps are off", - "Only when flipmaps are on", - "Auto-decide based on room type"}); - this.comboPlayMode.Location = new System.Drawing.Point(77, 486); - this.comboPlayMode.Name = "comboPlayMode"; - this.comboPlayMode.Size = new System.Drawing.Size(277, 23); - this.comboPlayMode.TabIndex = 2; + comboPlayMode.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + comboPlayMode.FormattingEnabled = true; + comboPlayMode.Items.AddRange(new object[] { "Always", "Only when flipmaps are off", "Only when flipmaps are on", "Auto-decide based on room type" }); + comboPlayMode.Location = new System.Drawing.Point(77, 486); + comboPlayMode.Name = "comboPlayMode"; + comboPlayMode.Size = new System.Drawing.Size(277, 23); + comboPlayMode.TabIndex = 2; // // darkLabel2 // - this.darkLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.darkLabel2.AutoSize = true; - this.darkLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); - this.darkLabel2.Location = new System.Drawing.Point(9, 489); - this.darkLabel2.Name = "darkLabel2"; - this.darkLabel2.Size = new System.Drawing.Size(62, 13); - this.darkLabel2.TabIndex = 63; - this.darkLabel2.Text = "Play mode:"; + darkLabel2.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left; + darkLabel2.AutoSize = true; + darkLabel2.ForeColor = System.Drawing.Color.FromArgb(220, 220, 220); + darkLabel2.Location = new System.Drawing.Point(9, 489); + darkLabel2.Name = "darkLabel2"; + darkLabel2.Size = new System.Drawing.Size(62, 13); + darkLabel2.TabIndex = 63; + darkLabel2.Text = "Play mode:"; // // butPlaySound // - this.butPlaySound.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.butPlaySound.Image = global::TombEditor.Properties.Resources.actions_play_16; - this.butPlaySound.Location = new System.Drawing.Point(360, 486); - this.butPlaySound.Name = "butPlaySound"; - this.butPlaySound.Size = new System.Drawing.Size(92, 23); - this.butPlaySound.TabIndex = 3; - this.butPlaySound.Text = "Play sound"; - this.butPlaySound.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - this.butPlaySound.Click += new System.EventHandler(this.butPlay_Click); + butPlaySound.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + butPlaySound.Checked = false; + butPlaySound.Image = Properties.Resources.actions_play_16; + butPlaySound.Location = new System.Drawing.Point(360, 486); + butPlaySound.Name = "butPlaySound"; + butPlaySound.Size = new System.Drawing.Size(92, 23); + butPlaySound.TabIndex = 3; + butPlaySound.Text = "Play sound"; + butPlaySound.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + butPlaySound.Click += butPlay_Click; // // lstSounds // - this.lstSounds.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lstSounds.Location = new System.Drawing.Point(8, 50); - this.lstSounds.Name = "lstSounds"; - this.lstSounds.Size = new System.Drawing.Size(444, 430); - this.lstSounds.TabIndex = 1; - this.lstSounds.Text = "darkListView1"; - this.lstSounds.Click += new System.EventHandler(this.lstSounds_Click); - this.lstSounds.DoubleClick += new System.EventHandler(this.lstSounds_DoubleClick); + lstSounds.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + lstSounds.Location = new System.Drawing.Point(8, 50); + lstSounds.Name = "lstSounds"; + lstSounds.Size = new System.Drawing.Size(444, 430); + lstSounds.TabIndex = 1; + lstSounds.Text = "darkListView1"; + lstSounds.Click += lstSounds_Click; + lstSounds.DoubleClick += lstSounds_DoubleClick; // // FormSoundSource // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.butCancel; - this.ClientSize = new System.Drawing.Size(484, 570); - this.Controls.Add(this.butOK); - this.Controls.Add(this.butCancel); - this.Controls.Add(this.optionPlaySoundFromWadGroupBox); - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(500, 520); - this.Name = "FormSoundSource"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Sound source"; - this.optionPlaySoundFromWadGroupBox.ResumeLayout(false); - this.optionPlaySoundFromWadGroupBox.PerformLayout(); - this.ResumeLayout(false); - + AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + CancelButton = butCancel; + ClientSize = new System.Drawing.Size(484, 570); + Controls.Add(cbSoundEnabled); + Controls.Add(butOK); + Controls.Add(butCancel); + Controls.Add(optionPlaySoundFromWadGroupBox); + MinimizeBox = false; + MinimumSize = new System.Drawing.Size(500, 520); + Name = "FormSoundSource"; + ShowIcon = false; + ShowInTaskbar = false; + SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + Text = "Sound source"; + optionPlaySoundFromWadGroupBox.ResumeLayout(false); + optionPlaySoundFromWadGroupBox.PerformLayout(); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -185,5 +190,6 @@ private void InitializeComponent() private DarkUI.Controls.DarkLabel darkLabel2; private DarkUI.Controls.DarkButton butSearch; private DarkUI.Controls.DarkTextBox tbSearch; + private DarkUI.Controls.DarkCheckBox cbSoundEnabled; } } \ No newline at end of file diff --git a/TombEditor/Forms/FormSoundSource.cs b/TombEditor/Forms/FormSoundSource.cs index 0256e5a1cf..96b12e7a5a 100644 --- a/TombEditor/Forms/FormSoundSource.cs +++ b/TombEditor/Forms/FormSoundSource.cs @@ -33,6 +33,10 @@ public FormSoundSource(SoundSourceInstance soundSource) lstSounds.Items.Add(new DarkUI.Controls.DarkListItem(sound.Id.ToString().PadLeft(4, '0') + ": " + sound.Name) { Tag = sound }); SelectSound(_soundSource.SoundId); + + bool isTEN = _editor.Level.Settings.GameVersion is TRVersion.Game.TombEngine; + cbSoundEnabled.Enabled = isTEN; + cbSoundEnabled.Visible = isTEN; } private void SelectSound(int id) @@ -70,6 +74,7 @@ private void butOK_Click(object sender, EventArgs e) { _soundSource.SoundId = _soundId; _soundSource.PlayMode = (SoundSourcePlayMode)comboPlayMode.SelectedIndex; + _soundSource.Enabled = cbSoundEnabled.Checked; DialogResult = DialogResult.OK; WadSoundPlayer.StopSample(); diff --git a/TombEditor/Forms/FormSoundSource.resx b/TombEditor/Forms/FormSoundSource.resx index 1af7de150c..8b2ff64a11 100644 --- a/TombEditor/Forms/FormSoundSource.resx +++ b/TombEditor/Forms/FormSoundSource.resx @@ -1,17 +1,17 @@  - diff --git a/TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs b/TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs index 5cec1787cd..094d4f2f13 100644 --- a/TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs +++ b/TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs @@ -204,6 +204,9 @@ private void PrepareSoundSources() flags |= 0x2000; break; } + + if (instance.Enabled) + flags |= 0x1000; Vector3 position = instance.Room.WorldPos + instance.Position; _soundSources.Add(new TombEngineSoundSource diff --git a/TombLib/TombLib/LevelData/IO/Prj2Loader.cs b/TombLib/TombLib/LevelData/IO/Prj2Loader.cs index 2dce8fb413..35c7617829 100644 --- a/TombLib/TombLib/LevelData/IO/Prj2Loader.cs +++ b/TombLib/TombLib/LevelData/IO/Prj2Loader.cs @@ -1571,6 +1571,7 @@ private static bool LoadObjects(ChunkReader chunkIO, ChunkId idOuter, LevelSetti instance.Position = chunkIO.Raw.ReadVector3(); instance.SoundId = chunkIO.Raw.ReadInt32(); instance.PlayMode = (SoundSourcePlayMode)chunkIO.Raw.ReadInt32(); + instance.Enabled = chunkIO.Raw.ReadBoolean(); instance.LuaName = chunkIO.Raw.ReadStringUTF8(); addObject(instance); newObjects.TryAdd(objectID, instance); diff --git a/TombLib/TombLib/LevelData/IO/Prj2Writer.cs b/TombLib/TombLib/LevelData/IO/Prj2Writer.cs index ebec3a9610..71dc12b5ee 100644 --- a/TombLib/TombLib/LevelData/IO/Prj2Writer.cs +++ b/TombLib/TombLib/LevelData/IO/Prj2Writer.cs @@ -740,6 +740,7 @@ private static void WriteObjects(ChunkWriter chunkIO, IEnumerable SoundId == -1; public WadSoundInfo GetSoundInfo(Level level) From 294445c78da2d462c464869802186cfa7b050edd Mon Sep 17 00:00:00 2001 From: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:11:55 -0500 Subject: [PATCH 2/3] Revert "Sound checkbox" This reverts commit cc5d70168423c9415b22b358f97ef7933e3fa811. --- TombEditor/Forms/FormSoundSource.Designer.cs | 236 +++++++++--------- TombEditor/Forms/FormSoundSource.cs | 5 - TombEditor/Forms/FormSoundSource.resx | 54 ++-- .../TombEngine/LevelCompilerTombEngine.cs | 3 - TombLib/TombLib/LevelData/IO/Prj2Loader.cs | 1 - TombLib/TombLib/LevelData/IO/Prj2Writer.cs | 1 - .../Instances/SoundSourceInstance.cs | 5 +- 7 files changed, 144 insertions(+), 161 deletions(-) diff --git a/TombEditor/Forms/FormSoundSource.Designer.cs b/TombEditor/Forms/FormSoundSource.Designer.cs index 4530ae6760..8142630bbe 100644 --- a/TombEditor/Forms/FormSoundSource.Designer.cs +++ b/TombEditor/Forms/FormSoundSource.Designer.cs @@ -28,156 +28,151 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - butOK = new DarkUI.Controls.DarkButton(); - butCancel = new DarkUI.Controls.DarkButton(); - optionPlaySoundFromWadGroupBox = new DarkUI.Controls.DarkGroupBox(); - cbSoundEnabled = new DarkUI.Controls.DarkCheckBox(); - butSearch = new DarkUI.Controls.DarkButton(); - tbSearch = new DarkUI.Controls.DarkTextBox(); - comboPlayMode = new DarkUI.Controls.DarkComboBox(); - darkLabel2 = new DarkUI.Controls.DarkLabel(); - butPlaySound = new DarkUI.Controls.DarkButton(); - lstSounds = new DarkUI.Controls.DarkListView(); - optionPlaySoundFromWadGroupBox.SuspendLayout(); - SuspendLayout(); + this.butOK = new DarkUI.Controls.DarkButton(); + this.butCancel = new DarkUI.Controls.DarkButton(); + this.optionPlaySoundFromWadGroupBox = new DarkUI.Controls.DarkGroupBox(); + this.butSearch = new DarkUI.Controls.DarkButton(); + this.tbSearch = new DarkUI.Controls.DarkTextBox(); + this.comboPlayMode = new DarkUI.Controls.DarkComboBox(); + this.darkLabel2 = new DarkUI.Controls.DarkLabel(); + this.butPlaySound = new DarkUI.Controls.DarkButton(); + this.lstSounds = new DarkUI.Controls.DarkListView(); + this.optionPlaySoundFromWadGroupBox.SuspendLayout(); + this.SuspendLayout(); // // butOK // - butOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - butOK.Checked = false; - butOK.Location = new System.Drawing.Point(306, 535); - butOK.Name = "butOK"; - butOK.Size = new System.Drawing.Size(80, 23); - butOK.TabIndex = 0; - butOK.Text = "OK"; - butOK.Click += butOK_Click; + this.butOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.butOK.Location = new System.Drawing.Point(306, 535); + this.butOK.Name = "butOK"; + this.butOK.Size = new System.Drawing.Size(80, 23); + this.butOK.TabIndex = 0; + this.butOK.Text = "OK"; + this.butOK.Click += new System.EventHandler(this.butOK_Click); // // butCancel // - butCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - butCancel.Checked = false; - butCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - butCancel.Location = new System.Drawing.Point(392, 535); - butCancel.Name = "butCancel"; - butCancel.Size = new System.Drawing.Size(80, 23); - butCancel.TabIndex = 1; - butCancel.Text = "Cancel"; - butCancel.Click += butCancel_Click; + this.butCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.butCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.butCancel.Location = new System.Drawing.Point(392, 535); + this.butCancel.Name = "butCancel"; + this.butCancel.Size = new System.Drawing.Size(80, 23); + this.butCancel.TabIndex = 1; + this.butCancel.Text = "Cancel"; + this.butCancel.Click += new System.EventHandler(this.butCancel_Click); // // optionPlaySoundFromWadGroupBox // - optionPlaySoundFromWadGroupBox.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - optionPlaySoundFromWadGroupBox.Controls.Add(butSearch); - optionPlaySoundFromWadGroupBox.Controls.Add(tbSearch); - optionPlaySoundFromWadGroupBox.Controls.Add(comboPlayMode); - optionPlaySoundFromWadGroupBox.Controls.Add(darkLabel2); - optionPlaySoundFromWadGroupBox.Controls.Add(butPlaySound); - optionPlaySoundFromWadGroupBox.Controls.Add(lstSounds); - optionPlaySoundFromWadGroupBox.Location = new System.Drawing.Point(12, 12); - optionPlaySoundFromWadGroupBox.Name = "optionPlaySoundFromWadGroupBox"; - optionPlaySoundFromWadGroupBox.Size = new System.Drawing.Size(460, 517); - optionPlaySoundFromWadGroupBox.TabIndex = 66; - optionPlaySoundFromWadGroupBox.TabStop = false; - optionPlaySoundFromWadGroupBox.Text = "Sound to play"; - // - // cbSoundEnabled - // - cbSoundEnabled.AutoSize = true; - cbSoundEnabled.Location = new System.Drawing.Point(12, 541); - cbSoundEnabled.Name = "cbSoundEnabled"; - cbSoundEnabled.Size = new System.Drawing.Size(68, 17); - cbSoundEnabled.TabIndex = 110; - cbSoundEnabled.Text = "Enabled"; + this.optionPlaySoundFromWadGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.optionPlaySoundFromWadGroupBox.Controls.Add(this.butSearch); + this.optionPlaySoundFromWadGroupBox.Controls.Add(this.tbSearch); + this.optionPlaySoundFromWadGroupBox.Controls.Add(this.comboPlayMode); + this.optionPlaySoundFromWadGroupBox.Controls.Add(this.darkLabel2); + this.optionPlaySoundFromWadGroupBox.Controls.Add(this.butPlaySound); + this.optionPlaySoundFromWadGroupBox.Controls.Add(this.lstSounds); + this.optionPlaySoundFromWadGroupBox.Location = new System.Drawing.Point(12, 12); + this.optionPlaySoundFromWadGroupBox.Name = "optionPlaySoundFromWadGroupBox"; + this.optionPlaySoundFromWadGroupBox.Size = new System.Drawing.Size(460, 517); + this.optionPlaySoundFromWadGroupBox.TabIndex = 66; + this.optionPlaySoundFromWadGroupBox.TabStop = false; + this.optionPlaySoundFromWadGroupBox.Text = "Sound to play"; // // butSearch // - butSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - butSearch.Checked = false; - butSearch.Image = Properties.Resources.general_search_16; - butSearch.Location = new System.Drawing.Point(428, 21); - butSearch.Name = "butSearch"; - butSearch.Selectable = false; - butSearch.Size = new System.Drawing.Size(24, 23); - butSearch.TabIndex = 109; - butSearch.Click += butSearch_Click; + this.butSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.butSearch.Image = global::TombEditor.Properties.Resources.general_search_16; + this.butSearch.Location = new System.Drawing.Point(428, 21); + this.butSearch.Name = "butSearch"; + this.butSearch.Selectable = false; + this.butSearch.Size = new System.Drawing.Size(24, 23); + this.butSearch.TabIndex = 109; + this.butSearch.Click += new System.EventHandler(this.butSearch_Click); // // tbSearch // - tbSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - tbSearch.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - tbSearch.Location = new System.Drawing.Point(8, 21); - tbSearch.Name = "tbSearch"; - tbSearch.Size = new System.Drawing.Size(421, 23); - tbSearch.TabIndex = 0; - tbSearch.KeyDown += tbSearch_KeyDown; + this.tbSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tbSearch.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.tbSearch.Location = new System.Drawing.Point(8, 21); + this.tbSearch.Name = "tbSearch"; + this.tbSearch.Size = new System.Drawing.Size(421, 23); + this.tbSearch.TabIndex = 0; + this.tbSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbSearch_KeyDown); // // comboPlayMode // - comboPlayMode.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - comboPlayMode.FormattingEnabled = true; - comboPlayMode.Items.AddRange(new object[] { "Always", "Only when flipmaps are off", "Only when flipmaps are on", "Auto-decide based on room type" }); - comboPlayMode.Location = new System.Drawing.Point(77, 486); - comboPlayMode.Name = "comboPlayMode"; - comboPlayMode.Size = new System.Drawing.Size(277, 23); - comboPlayMode.TabIndex = 2; + this.comboPlayMode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.comboPlayMode.FormattingEnabled = true; + this.comboPlayMode.Items.AddRange(new object[] { + "Always", + "Only when flipmaps are off", + "Only when flipmaps are on", + "Auto-decide based on room type"}); + this.comboPlayMode.Location = new System.Drawing.Point(77, 486); + this.comboPlayMode.Name = "comboPlayMode"; + this.comboPlayMode.Size = new System.Drawing.Size(277, 23); + this.comboPlayMode.TabIndex = 2; // // darkLabel2 // - darkLabel2.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left; - darkLabel2.AutoSize = true; - darkLabel2.ForeColor = System.Drawing.Color.FromArgb(220, 220, 220); - darkLabel2.Location = new System.Drawing.Point(9, 489); - darkLabel2.Name = "darkLabel2"; - darkLabel2.Size = new System.Drawing.Size(62, 13); - darkLabel2.TabIndex = 63; - darkLabel2.Text = "Play mode:"; + this.darkLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.darkLabel2.AutoSize = true; + this.darkLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); + this.darkLabel2.Location = new System.Drawing.Point(9, 489); + this.darkLabel2.Name = "darkLabel2"; + this.darkLabel2.Size = new System.Drawing.Size(62, 13); + this.darkLabel2.TabIndex = 63; + this.darkLabel2.Text = "Play mode:"; // // butPlaySound // - butPlaySound.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - butPlaySound.Checked = false; - butPlaySound.Image = Properties.Resources.actions_play_16; - butPlaySound.Location = new System.Drawing.Point(360, 486); - butPlaySound.Name = "butPlaySound"; - butPlaySound.Size = new System.Drawing.Size(92, 23); - butPlaySound.TabIndex = 3; - butPlaySound.Text = "Play sound"; - butPlaySound.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - butPlaySound.Click += butPlay_Click; + this.butPlaySound.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.butPlaySound.Image = global::TombEditor.Properties.Resources.actions_play_16; + this.butPlaySound.Location = new System.Drawing.Point(360, 486); + this.butPlaySound.Name = "butPlaySound"; + this.butPlaySound.Size = new System.Drawing.Size(92, 23); + this.butPlaySound.TabIndex = 3; + this.butPlaySound.Text = "Play sound"; + this.butPlaySound.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.butPlaySound.Click += new System.EventHandler(this.butPlay_Click); // // lstSounds // - lstSounds.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - lstSounds.Location = new System.Drawing.Point(8, 50); - lstSounds.Name = "lstSounds"; - lstSounds.Size = new System.Drawing.Size(444, 430); - lstSounds.TabIndex = 1; - lstSounds.Text = "darkListView1"; - lstSounds.Click += lstSounds_Click; - lstSounds.DoubleClick += lstSounds_DoubleClick; + this.lstSounds.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lstSounds.Location = new System.Drawing.Point(8, 50); + this.lstSounds.Name = "lstSounds"; + this.lstSounds.Size = new System.Drawing.Size(444, 430); + this.lstSounds.TabIndex = 1; + this.lstSounds.Text = "darkListView1"; + this.lstSounds.Click += new System.EventHandler(this.lstSounds_Click); + this.lstSounds.DoubleClick += new System.EventHandler(this.lstSounds_DoubleClick); // // FormSoundSource // - AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - CancelButton = butCancel; - ClientSize = new System.Drawing.Size(484, 570); - Controls.Add(cbSoundEnabled); - Controls.Add(butOK); - Controls.Add(butCancel); - Controls.Add(optionPlaySoundFromWadGroupBox); - MinimizeBox = false; - MinimumSize = new System.Drawing.Size(500, 520); - Name = "FormSoundSource"; - ShowIcon = false; - ShowInTaskbar = false; - SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - Text = "Sound source"; - optionPlaySoundFromWadGroupBox.ResumeLayout(false); - optionPlaySoundFromWadGroupBox.PerformLayout(); - ResumeLayout(false); - PerformLayout(); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.butCancel; + this.ClientSize = new System.Drawing.Size(484, 570); + this.Controls.Add(this.butOK); + this.Controls.Add(this.butCancel); + this.Controls.Add(this.optionPlaySoundFromWadGroupBox); + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(500, 520); + this.Name = "FormSoundSource"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Sound source"; + this.optionPlaySoundFromWadGroupBox.ResumeLayout(false); + this.optionPlaySoundFromWadGroupBox.PerformLayout(); + this.ResumeLayout(false); + } #endregion @@ -190,6 +185,5 @@ private void InitializeComponent() private DarkUI.Controls.DarkLabel darkLabel2; private DarkUI.Controls.DarkButton butSearch; private DarkUI.Controls.DarkTextBox tbSearch; - private DarkUI.Controls.DarkCheckBox cbSoundEnabled; } } \ No newline at end of file diff --git a/TombEditor/Forms/FormSoundSource.cs b/TombEditor/Forms/FormSoundSource.cs index 96b12e7a5a..0256e5a1cf 100644 --- a/TombEditor/Forms/FormSoundSource.cs +++ b/TombEditor/Forms/FormSoundSource.cs @@ -33,10 +33,6 @@ public FormSoundSource(SoundSourceInstance soundSource) lstSounds.Items.Add(new DarkUI.Controls.DarkListItem(sound.Id.ToString().PadLeft(4, '0') + ": " + sound.Name) { Tag = sound }); SelectSound(_soundSource.SoundId); - - bool isTEN = _editor.Level.Settings.GameVersion is TRVersion.Game.TombEngine; - cbSoundEnabled.Enabled = isTEN; - cbSoundEnabled.Visible = isTEN; } private void SelectSound(int id) @@ -74,7 +70,6 @@ private void butOK_Click(object sender, EventArgs e) { _soundSource.SoundId = _soundId; _soundSource.PlayMode = (SoundSourcePlayMode)comboPlayMode.SelectedIndex; - _soundSource.Enabled = cbSoundEnabled.Checked; DialogResult = DialogResult.OK; WadSoundPlayer.StopSample(); diff --git a/TombEditor/Forms/FormSoundSource.resx b/TombEditor/Forms/FormSoundSource.resx index 8b2ff64a11..1af7de150c 100644 --- a/TombEditor/Forms/FormSoundSource.resx +++ b/TombEditor/Forms/FormSoundSource.resx @@ -1,17 +1,17 @@  - diff --git a/TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs b/TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs index 094d4f2f13..5cec1787cd 100644 --- a/TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs +++ b/TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs @@ -204,9 +204,6 @@ private void PrepareSoundSources() flags |= 0x2000; break; } - - if (instance.Enabled) - flags |= 0x1000; Vector3 position = instance.Room.WorldPos + instance.Position; _soundSources.Add(new TombEngineSoundSource diff --git a/TombLib/TombLib/LevelData/IO/Prj2Loader.cs b/TombLib/TombLib/LevelData/IO/Prj2Loader.cs index 35c7617829..2dce8fb413 100644 --- a/TombLib/TombLib/LevelData/IO/Prj2Loader.cs +++ b/TombLib/TombLib/LevelData/IO/Prj2Loader.cs @@ -1571,7 +1571,6 @@ private static bool LoadObjects(ChunkReader chunkIO, ChunkId idOuter, LevelSetti instance.Position = chunkIO.Raw.ReadVector3(); instance.SoundId = chunkIO.Raw.ReadInt32(); instance.PlayMode = (SoundSourcePlayMode)chunkIO.Raw.ReadInt32(); - instance.Enabled = chunkIO.Raw.ReadBoolean(); instance.LuaName = chunkIO.Raw.ReadStringUTF8(); addObject(instance); newObjects.TryAdd(objectID, instance); diff --git a/TombLib/TombLib/LevelData/IO/Prj2Writer.cs b/TombLib/TombLib/LevelData/IO/Prj2Writer.cs index 71dc12b5ee..ebec3a9610 100644 --- a/TombLib/TombLib/LevelData/IO/Prj2Writer.cs +++ b/TombLib/TombLib/LevelData/IO/Prj2Writer.cs @@ -740,7 +740,6 @@ private static void WriteObjects(ChunkWriter chunkIO, IEnumerable SoundId == -1; public WadSoundInfo GetSoundInfo(Level level) From bae1919433d784d177a0f5e125f44b29bbb00768 Mon Sep 17 00:00:00 2001 From: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Sun, 10 May 2026 13:52:50 -0400 Subject: [PATCH 3/3] WIP --- TombEditor/Controls/Panel3D/Panel3DDraw.cs | 10 ++++-- TombEditor/ToolWindows/Lighting.cs | 13 ++++++-- .../Rendering/ServiceObjectTextures.cs | 8 +++++ .../ServiceObjectTextures/light_glow.png | Bin 0 -> 7144 bytes .../ServiceObjectTextures/light_move.png | Bin 0 -> 6744 bytes .../TombLib.Rendering.csproj | 2 ++ TombLib/TombLib/LevelData/Compilers/Rooms.cs | 2 ++ .../LevelData/Compilers/TombEngine/Rooms.cs | 31 ++++++++++++++++++ .../LevelData/Instances/LightInstance.cs | 7 +++- TombLib/TombLib/LevelData/RoomGeometry.cs | 23 +++++++++++++ 10 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 TombLib/TombLib.Rendering/Rendering/ServiceObjectTextures/light_glow.png create mode 100644 TombLib/TombLib.Rendering/Rendering/ServiceObjectTextures/light_move.png diff --git a/TombEditor/Controls/Panel3D/Panel3DDraw.cs b/TombEditor/Controls/Panel3D/Panel3DDraw.cs index dd6229218d..a650bdbcb8 100644 --- a/TombEditor/Controls/Panel3D/Panel3DDraw.cs +++ b/TombEditor/Controls/Panel3D/Panel3DDraw.cs @@ -519,6 +519,10 @@ private void DrawLights(Effect effect, Room[] roomsWhoseObjectsToDraw, ListFv!p)5%f715@Mq{xw-a7y+h z2}P1aNwRiw>i3S8Q`hf%UBByG*YEt-%r*1Qdq4O6d7k@of9~gcpGmZ}wvZH45(9xi zl6Xr~d*JHE|Ev=RzMaGqN`Omqgrh6Zo)`*db67NbAQj9DXH&t{Fggtc3VX`1HCo>c zURN`h6nR+CKKwXim=b-n%Uky8?GEb~322(^g=j-on4}MFq}0(ajp9RXp_vhm>*(#s z)wjdc9PA&(bgPx-thlPb-4?M&=wN_z#y;EOyRI`wI4}DxZ1qjYEc{xOjg*Yym@n7) zJ#*er+*Tf6p1->gu5f$dY!0VpQGbrqJD8jp_oS6VhRjNJy9z$Ku93cJKQpAaTcGy>b8~enlS;Zu{ zG&u>Ixl69mn67zy%7-%v_aj-_dv00Ve>m1qu4p~1vkG@d?C^+`^k-0zJuhuT{b^bE z<}miq(a7H0C*Q(>(;&wVROz)mSB)D9jV^1X1*IDgHCq|vc-(K|9vp7E*I$k8 zdcS9BB0)nvU0_cdwvpEa@!F9)aGTfpvDwZ!L-qytg=j3ya^-&Tz_@PbrlV_f6}8_F z=)KUm$*_&A~jfm%4P?J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4ZSu0$xcr(IRQT%bv-%Jb)fY?c;qlsx4fdl!Nf!exQMKH zYb?m(uZ@q+j@=^;v?7<5@1`*y&yKiBHOiG*X3-BUEWf;!eE#K@^V!+SRrNC|2G|_y zJD#v7fxjKXniU+X(Z5;3vx#k#UZ`X*FQh+oMmm{}zU(u`<-iJdYkAAQo|=lwcr2WJ z_m+BTU9#2o^zQ2kEu>jZp%EgF_o(ZWoSpsawY~-;nU8W$)yO(g%wJjq@1Y(;JSx4W8VI)vz5b4L-euzpn-;{g0-mM_3ENU+MH7#7)q>PFSc(|K|;9x7$)0m zYHI5J+C`|GxRzWp!d*mISo&D1R%Z--S*7%?vGNvDFcXX0EoWO$jg>Dv>_;GMGJU_c zWpn-swBe}*8AhCgk!+XfhK03dCS=L*t4{;aZB7J{%RzSl?DYfjZIs2p4Ln{Yer zn3vHAV_WB=N6IwbZ}X2F5w6EO zxwwd5rV@!U^AVAz5yZUGkITR|3iLh4-Q2<=zUR`-RCsWS+yh_#r)g7AO+tlI87_CB z!o6z3Myfh*+_>>)yyL~gH_8I-Br2jy|9IqdXWc`?4^YQ$!+{FP&0;wXnn04~Glz*m zL22@D(z5B}wu*-rZ?l+8XM)Xvia`SK61kCIt3Nm_9N(*mLZRYvJKs(9X;y{L(F%GM zpUPbFj(2~j>@g#8b^Lgr|CPGBx=0pCEPi^LG4=YjYEhrk)VVa#Eho6x_vn$Wg@p(d1~a$n58?5;uk1UmfkvYrCF(H~I}5ZIZTkjnKt8Cmwyv%TD=PiuTW=a`0c z^}Y~u{|%?QED0y)tIbj6I-nK7akPDOBk;g@Y~72`MzS@p6=#M`fJa&o-ptzchOy7# F{{icbZ4v+g literal 0 HcmV?d00001 diff --git a/TombLib/TombLib.Rendering/Rendering/ServiceObjectTextures/light_move.png b/TombLib/TombLib.Rendering/Rendering/ServiceObjectTextures/light_move.png new file mode 100644 index 0000000000000000000000000000000000000000..90badce80035745ff70279d8c11fd9b33949792b GIT binary patch literal 6744 zcmeHKc{tSj_a940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4CY%$1kbUcTJ(079;&rbbC#*55AKYVnTO zYmM_y5sHh8ZHO7p$y>EgUFxdH%v>HreX+f6BEIchfO5mZHo|a$L&nC{4;Iil@1_$j zl(o;*Fou9@2qjPcj+fzHOi+|;LFn@kNrjScVk_WyzBAi1e_o!T@dSo>btAdKx7GcE zjph)UR*?L9@xX>x105wXUgS52oTfW;nH)gg+8XKa58V;;NHN;xTIi7P-S$$Zy=3uwjg5Kv`7Xhs z2UPW}?iFskLK(b!Y5&rW)eT2AKORnPW{iq0L}GEOTY##nYJK;}ZyoHrCwJSYy2?#z zn1nQ4C@NYh>2l7=$tkU@x zYuo?lpPoKf`7&@gJdn+TLYzM)#=uMEF8B-SCsT@g6vt#;psmfcPN}Q sz5IfmgOAM;>CMpZ18Q@Wdupd4rO)-6>#86C_z4AZv~wmEt@n@m54XRyp#T5? literal 0 HcmV?d00001 diff --git a/TombLib/TombLib.Rendering/TombLib.Rendering.csproj b/TombLib/TombLib.Rendering/TombLib.Rendering.csproj index ebef71ddd4..b5f789970b 100644 --- a/TombLib/TombLib.Rendering/TombLib.Rendering.csproj +++ b/TombLib/TombLib.Rendering/TombLib.Rendering.csproj @@ -157,6 +157,8 @@ + + diff --git a/TombLib/TombLib/LevelData/Compilers/Rooms.cs b/TombLib/TombLib/LevelData/Compilers/Rooms.cs index 1224b8a2dc..6507f422a1 100644 --- a/TombLib/TombLib/LevelData/Compilers/Rooms.cs +++ b/TombLib/TombLib/LevelData/Compilers/Rooms.cs @@ -1240,6 +1240,8 @@ private void ConvertLights(Room room, tr_room newRoom) newLight.Length = light.Intensity; // Store float intensity as length break; case LightType.Effect: + case LightType.Glow: + case LightType.Move: continue; default: throw new Exception("Unknown light type '" + light.Type + "' encountered."); diff --git a/TombLib/TombLib/LevelData/Compilers/TombEngine/Rooms.cs b/TombLib/TombLib/LevelData/Compilers/TombEngine/Rooms.cs index e05d8b4859..7c5b02aa06 100644 --- a/TombLib/TombLib/LevelData/Compilers/TombEngine/Rooms.cs +++ b/TombLib/TombLib/LevelData/Compilers/TombEngine/Rooms.cs @@ -282,6 +282,8 @@ private TombEngineRoom BuildRoom(Room room) } } + int importedGeometryVertexStart = 0; + // Generate geometry { // Add room geometry @@ -555,6 +557,7 @@ private TombEngineRoom BuildRoom(Room room) // Add geometry imported objects + importedGeometryVertexStart = roomVertices.Count; foreach (var geometry in room.Objects.OfType()) { if (geometry.Model?.DirectXModel == null) @@ -731,6 +734,10 @@ private TombEngineRoom BuildRoom(Room room) // Assign vertex effects + var vertexEffectLights = room.Objects.OfType() + .Where(l => l.Enabled && (l.Type == LightType.Glow || l.Type == LightType.Move)) + .ToList(); + for (int i = 0; i < newRoom.Vertices.Count; ++i) { var trVertex = newRoom.Vertices[i]; @@ -739,9 +746,31 @@ private TombEngineRoom BuildRoom(Room room) var xv = (int)(trVertex.Position.X / Level.SectorSizeUnit); var zv = (int)(trVertex.Position.Z / Level.SectorSizeUnit); + // Apply vertex effects from Glow and Move light objects to all vertices, + // including border/wall vertices that are skipped by the sector bounds check below. + var vertexPosLocal = new Vector3(trVertex.Position.X, -trVertex.Position.Y - room.WorldPos.Y, trVertex.Position.Z); + bool isImportedGeometryVertex = i >= importedGeometryVertexStart; + foreach (var effectLight in vertexEffectLights) + { + if (isImportedGeometryVertex && !effectLight.IsUsedForImportedGeometry) + continue; + + float strength = RoomGeometry.CalculateVertexEffectStrength(room, effectLight, vertexPosLocal); + if (strength <= 0f) + continue; + + if (effectLight.Type == LightType.Glow) + trVertex.Glow = Math.Max(trVertex.Glow, strength); + else if (effectLight.Type == LightType.Move) + trVertex.Move = Math.Max(trVertex.Move, strength); + } + // Check for vertex out of room bounds if (xv <= 0 || zv <= 0 || xv >= room.NumXSectors || zv >= room.NumZSectors) + { + newRoom.Vertices[i] = trVertex; continue; + } foreach (var portal in room.PortalsCache) { @@ -1001,6 +1030,8 @@ private void ConvertLights(Room room, TombEngineRoom newRoom) newLight.Out = light.OuterRange * Level.SectorSizeUnit; break; case LightType.Effect: + case LightType.Glow: + case LightType.Move: continue; default: throw new Exception("Unknown light type '" + light.Type + "' encountered."); diff --git a/TombLib/TombLib/LevelData/Instances/LightInstance.cs b/TombLib/TombLib/LevelData/Instances/LightInstance.cs index 8ff5cdaa40..cd3e731df0 100644 --- a/TombLib/TombLib/LevelData/Instances/LightInstance.cs +++ b/TombLib/TombLib/LevelData/Instances/LightInstance.cs @@ -9,7 +9,7 @@ public enum LightQuality : byte } public enum LightType : byte { - Point, Shadow, Spot, Effect, Sun, FogBulb + Point, Shadow, Spot, Effect, Sun, FogBulb, Glow, Move } public class LightInstance : PositionBasedObjectInstance, IColorable, IReplaceable, IRotateableYX @@ -65,6 +65,11 @@ public LightInstance(LightType type) IsStaticallyUsed = false; IsUsedForImportedGeometry = false; break; + case LightType.Glow: + case LightType.Move: + IsDynamicallyUsed = false; + CastDynamicShadows = false; + break; } } diff --git a/TombLib/TombLib/LevelData/RoomGeometry.cs b/TombLib/TombLib/LevelData/RoomGeometry.cs index 5276002643..b25959b982 100644 --- a/TombLib/TombLib/LevelData/RoomGeometry.cs +++ b/TombLib/TombLib/LevelData/RoomGeometry.cs @@ -1163,6 +1163,7 @@ public static Vector3 CalculateLightForVertex(Room room, LightInstance light, Ve LightType.Effect => CalculateEffectLight(light, position), LightType.Sun => CalculateSunLight(room, light, position, normal, highQuality), LightType.Spot => CalculateSpotLight(room, light, position, normal, highQuality), + LightType.Glow or LightType.Move => Vector3.Zero, _ => Vector3.Zero }; } @@ -1229,6 +1230,28 @@ private static Vector3 CalculateEffectLight(LightInstance light, Vector3 positio return finalIntensity * light.Color * ColorNormalization; } + // Calculates the strength of a Glow or Move vertex effect at a given position. + // Returns a value in [0, 1] based on linear falloff from InnerRange to OuterRange, + // scaled by Intensity. Respects IsObstructedByRoomGeometry via raytrace. + public static float CalculateVertexEffectStrength(Room room, LightInstance light, Vector3 position) + { + float distance = Vector3.Distance(position, light.Position); + float outerRadius = light.OuterRange * Level.SectorSizeUnit; + + if (distance > outerRadius) + return 0.0f; + + float innerRadius = light.InnerRange * Level.SectorSizeUnit; + float rangeDelta = outerRadius - innerRadius; + float attenuation = rangeDelta > 0 ? Math.Clamp((outerRadius - distance) / rangeDelta, 0.0f, 1.0f) : 1.0f; + + if (attenuation <= 0.0f) + return 0.0f; + + float raytraceResult = light.IsObstructedByRoomGeometry && LightRayTrace(room, position, light.Position) ? 0.0f : 1.0f; + return Math.Clamp(light.Intensity * attenuation * raytraceResult, 0.0f, 1.0f); + } + private static Vector3 CalculateSunLight(Room room, LightInstance light, Vector3 position, Vector3 normal, bool highQuality) {