Solutions
This commit is contained in:
parent
cc7c6af33f
commit
fcdd47e200
28 changed files with 88 additions and 60 deletions
|
|
@ -16,31 +16,37 @@ func update_material(substances: Array[RuntimeSubstanceData]) -> void:
|
|||
visible = true
|
||||
|
||||
var total_weight = 0
|
||||
var total_color = 0
|
||||
|
||||
for sub in substances:
|
||||
total_weight += sub.amount
|
||||
total_color += sub.substance.color_influence
|
||||
|
||||
var pH: float = 0
|
||||
var color: Color = Color(0,0,0,0)
|
||||
|
||||
|
||||
for sub: RuntimeSubstanceData in substances:
|
||||
var weight: float = sub.amount/total_weight
|
||||
pH += sub.substance.get_ph_runtime(substances) * weight
|
||||
|
||||
for sub: RuntimeSubstanceData in substances:
|
||||
var weight: float = sub.amount/total_weight
|
||||
if display_type == DisplayType.Fluid:
|
||||
pass
|
||||
var color_to_add: Color
|
||||
if sub.substance.pHColor != null:
|
||||
color += sub.substance.pHColor.sample(pH/14.0) * weight
|
||||
color_to_add = sub.substance.pHColor.sample(pH/14.0)
|
||||
else:
|
||||
color += sub.substance.color * weight
|
||||
|
||||
if display_type == DisplayType.Fluid:
|
||||
pass
|
||||
color_to_add = sub.substance.color
|
||||
|
||||
if display_type == DisplayType.Fluid and sub.is_solution:
|
||||
color_to_add.a = 0.5
|
||||
|
||||
#if color == Color(0,0,0,0):
|
||||
# color = color_to_add
|
||||
#else:
|
||||
# color = color.lerp(color_to_add,sub.substance.color_influence)
|
||||
color += color_to_add * sub.substance.color_influence
|
||||
|
||||
|
||||
mat.albedo_color = color
|
||||
mat.albedo_color = color / total_color
|
||||
|
||||
func update_material_unfiltered(substances: Array[RuntimeSubstanceData]):
|
||||
match display_type:
|
||||
|
|
@ -51,5 +57,5 @@ func update_material_unfiltered(substances: Array[RuntimeSubstanceData]):
|
|||
var solids = substances.filter(filter_solids)
|
||||
update_material(solids)
|
||||
|
||||
func filter_liquids(sub: RuntimeSubstanceData): return sub.substance.melting_point < sub.temperature or sub.substance.is_solution
|
||||
func filter_solids(sub: RuntimeSubstanceData): return sub.substance.melting_point > sub.temperature and not sub.substance.is_solution
|
||||
func filter_liquids(sub: RuntimeSubstanceData): return sub.substance.melting_point < sub.temperature or sub.is_solution
|
||||
func filter_solids(sub: RuntimeSubstanceData): return sub.substance.melting_point > sub.temperature and not sub.is_solution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue