Add anatomical character customization at initial creation

This commit is contained in:
dingo
2026-09-12 16:00:15 -04:00
parent 90e33cbcd9
commit 4aca703b6f
25 changed files with 733 additions and 133 deletions
+30 -1
View File
@@ -24,12 +24,41 @@ func ValidateAppearance(a *Appearance, families ...string) error {
if a == nil {
return nil
} // Existing worlds retain their original models.
if !slices.Contains(families, a.Family) || a.Version != 1 || a.Variant < 0 || a.Variant > 3 || a.Seed < 1 || a.Seed > 65535 || !finiteRange(a.Height, .75, 1.25) || !finiteRange(a.Width, .75, 1.25) || !finiteRange(a.Detail, 0, 1) || !appearanceColor.MatchString(a.Primary) || !appearanceColor.MatchString(a.Secondary) || !appearanceColor.MatchString(a.Accent) {
if !slices.Contains(families, a.Family) || (a.Version != 1 && a.Version != 2) || a.Variant < 0 || a.Variant > 3 || a.Seed < 1 || a.Seed > 65535 || !finiteRange(a.Height, .75, 1.25) || !finiteRange(a.Width, .75, 1.25) || !finiteRange(a.Detail, 0, 1) || !appearanceColor.MatchString(a.Primary) || !appearanceColor.MatchString(a.Secondary) || !appearanceColor.MatchString(a.Accent) {
return fmt.Errorf("invalid appearance: choose a supported form, bounded proportions, and six-digit colors")
}
if a.Version == 1 {
if a.Body != nil {
return fmt.Errorf("legacy appearance cannot include anatomy")
}
return nil
}
b := a.Body
if a.Family != "human" || b == nil || !finiteRange(a.Height, .9, 1.1) || a.Width != 1 || !appearanceColor.MatchString(b.EyeColor) || !slices.Contains([]string{"none", "thin", "bushy"}, b.Eyebrows) || !slices.Contains([]string{"neutral", "smile", "stern"}, b.MouthStyle) || !slices.Contains([]string{"male", "female"}, b.Chest) {
return fmt.Errorf("invalid humanoid anatomy")
}
for _, v := range []float64{b.HeadLength, b.HeadWidth, b.HeadDepth, b.ChestWidth, b.HipsWidth, b.FootSize} {
if !finiteRange(v, .85, 1.15) {
return fmt.Errorf("body proportion outside supported range")
}
}
for _, v := range []float64{b.EyeSpacing, b.ArmWidth, b.LegWidth} {
if !finiteRange(v, .8, 1.2) {
return fmt.Errorf("body width outside supported range")
}
}
if !finiteRange(b.ArmLength, .9, 1.1) || !finiteRange(b.LegLength, .9, 1.1) || !finiteRange(b.NoseScale, .75, 1.25) || !finiteRange(b.EyeHeight, -.035, .035) || !finiteRange(b.NoseHeight, -.035, .035) || !finiteRange(b.MouthHeight, -.025, .025) {
return fmt.Errorf("facial feature or limb outside supported range")
}
return nil
}
func DefaultCharacterAppearance() *Appearance {
return &Appearance{Version: 2, Family: "human", Seed: 42, Height: 1, Width: 1, Detail: .5, Primary: "#c99573", Secondary: "#392b28", Accent: "#456c70", Body: &p.HumanoidBody{
HeadLength: 1, HeadWidth: 1, HeadDepth: 1, EyeSpacing: 1, EyeColor: "#547d75", Eyebrows: "thin", NoseScale: 1, MouthStyle: "neutral", Chest: "male", ChestWidth: 1, HipsWidth: 1, ArmLength: 1, ArmWidth: 1, LegLength: 1, LegWidth: 1, FootSize: 1,
}}
}
func (c Catalog) validateVisuals() error {
if len(c.Visuals) > 1024 {
return fmt.Errorf("visual library is full")