Skip to content

Commit

Permalink
Added volume displacement ratio settings to config.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
scfmod committed Jan 8, 2022
1 parent 0e6a7c6 commit 35276bc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
26 changes: 25 additions & 1 deletion classes/TerraFarmConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
---@field terraformFlattenRadius number
---@field terraformDisablePaint boolean
---@field dischargePaintLayer string
---@field raiseDisplacementVolumeRatio number
---@field lowerDisplacementVolumeRatio number
---@field flattenDisplacementVolumeRatio number
---@field flattenDischargeDisplacementVolumeRatio number
TerraFarmConfig = {}
local TerraFarmConfig_mt = Class(TerraFarmConfig)

Expand All @@ -39,7 +43,12 @@ TerraFarmConfig.DEFAULT = {
terraformFlattenStrength = 50.0,
terraformFlattenRadius = 2.0,
terraformDisablePaint = false,
dischargePaintLayer = 'dirt'
dischargePaintLayer = 'dirt',

raiseDisplacementVolumeRatio = 1.0,
lowerDisplacementVolumeRatio = 1.618,
flattenDisplacementVolumeRatio = 1.0,
flattenDischargeDisplacementVolumeRatio = 0.5
}

TerraFarmConfig.RADIUS_MIN = 0.1
Expand Down Expand Up @@ -139,6 +148,13 @@ function TerraFarmConfig.loadXML()
self.terraformFlattenStrength = getConfigFloat(xmlFile, 'terraFarm.defaults', 'terraformFlattenStrength')
self.terraformFlattenRadius = getConfigFloat(xmlFile, 'terraFarm.defaults', 'terraformFlattenRadius')

-- VOLUME DISPLACEMENT RATIOS

self.raiseDisplacementVolumeRatio = getConfigFloat(xmlFile, 'terraFarm.settings', 'raiseDisplacementVolumeRatio')
self.lowerDisplacementVolumeRatio = getConfigFloat(xmlFile, 'terraFarm.settings', 'lowerDisplacementVolumeRatio')
self.flattenDisplacementVolumeRatio = getConfigFloat(xmlFile, 'terraFarm.settings', 'flattenDisplacementVolumeRatio')
self.flattenDischargeDisplacementVolumeRatio = getConfigFloat(xmlFile, 'terraFarm.settings', 'flattenDischargeDisplacementVolumeRatio')

delete(xmlFile)

if g_terraFarm and g_terraFarm:updateFillTypeData() ~= true then
Expand Down Expand Up @@ -184,6 +200,14 @@ function TerraFarmConfig:save()
setXMLFloat(xmlFile, 'terraFarm.defaults.terraformFlattenStrength', self.terraformFlattenStrength)
setXMLFloat(xmlFile, 'terraFarm.defaults.terraformFlattenRadius', self.terraformFlattenRadius)


-- VOLUME DISPLACEMENT RATIOS

setXMLFloat(xmlFile, 'terraFarm.settings.raiseDisplacementVolumeRatio', self.raiseDisplacementVolumeRatio)
setXMLFloat(xmlFile, 'terraFarm.settings.lowerDisplacementVolumeRatio', self.lowerDisplacementVolumeRatio)
setXMLFloat(xmlFile, 'terraFarm.settings.flattenDisplacementVolumeRatio', self.flattenDisplacementVolumeRatio)
setXMLFloat(xmlFile, 'terraFarm.settings.flattenDischargeDisplacementVolumeRatio', self.flattenDischargeDisplacementVolumeRatio)

saveXMLFile(xmlFile)
delete(xmlFile)
end
12 changes: 8 additions & 4 deletions classes/TerraFarmLandscaping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,18 @@ function TerraFarmLandscaping:onSculptingApplied(errorCode, displacedVolumeOrAre

if machine ~= nil and machine.onVolumeDisplacement ~= nil then
if self.operation == TerraFarmLandscaping.OPERATION.RAISE then
machine:onVolumeDisplacement(-displacedVolumeOrArea)
-- machine:onVolumeDisplacement(-displacedVolumeOrArea)
machine:onVolumeDisplacement(-displacedVolumeOrArea * g_terraFarm.config.raiseDisplacementVolumeRatio)
elseif self.operation == TerraFarmLandscaping.OPERATION.LOWER then
machine:onVolumeDisplacement(displacedVolumeOrArea * 1.618)
-- machine:onVolumeDisplacement(displacedVolumeOrArea * 1.618)
machine:onVolumeDisplacement(displacedVolumeOrArea * g_terraFarm.config.lowerDisplacementVolumeRatio)
elseif self.operation == TerraFarmLandscaping.OPERATION.FLATTEN then
if self.isDischarging then
machine:onVolumeDisplacement(displacedVolumeOrArea * -0.5)
-- machine:onVolumeDisplacement(displacedVolumeOrArea * -0.5)
machine:onVolumeDisplacement(displacedVolumeOrArea * g_terraFarm.config.flattenDischargeDisplacementVolumeRatio * -1.0)
else
machine:onVolumeDisplacement(displacedVolumeOrArea)
-- machine:onVolumeDisplacement(displacedVolumeOrArea)
machine:onVolumeDisplacement(displacedVolumeOrArea * g_terraFarm.config.flattenDisplacementVolumeRatio)
end
end
else
Expand Down

0 comments on commit 35276bc

Please sign in to comment.