Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#4992 closed defect (fixed)

Use vectors not only in rmgen scripts but also for arguments in the rmgen library

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 23
Component: Maps Keywords:
Cc: Patch:


Since now (#4845) most of the maps use vector algebra to simplify equations by a lot, the basic rmgen tools should also use vectors when passing arguments. This way the vector objects have only to be created once and can be passed back and forth, it's globally consistent.

Also it was likely envisioned once upon a time by the point.js file from r9096. That commit also introduced the Vector.js code but somehow didn't use it.

For instance:

  • Placers
  • Painters
  • Constaints
  • Areas
  • getHeight, setHeight
  • placeObject

Change History (21)

comment:1 by elexis, 5 years ago

In 20935:

Pass vectors from paintRiver to the map script, refs #4992.

comment:2 by elexis, 5 years ago

In 20943:

Unify Corsica & Sardinia and Pyrennean Sierra slope and smoothened height computation, refs #4805, rP11266, rP12248.
Receive vectors as arguments, refs #4992 and don't introduce a RandomMap object proxy.

comment:3 by elexis, 5 years ago

I'm aware that there's a performance cost to creating the vectors and that in some cases we don't have a vector yet. However that's a fraction of a second in any case currently. The thing that costs performance are the retries and some unluckily chosen numbers for the ClumpPlacer.

In r20936:

Use vectors for positions in setHeight in random map scripts.

comment:4 by elexis, 5 years ago

In 20970:

Pass position vectors to the PathPlacer rather than each component individually, refs #4992.

Every PathPlacer constructor already has the two vectors in place, refs #4845.
The code becomes shorter (operations not copied once per dimension) and more readable (normalize, perpendicular).
Performance can improve even.

comment:5 by elexis, 5 years ago

In 20971:

Pass a vector to the ClumpPlacer instead of the vector components individually, refs #4992.
Support non-integer values and remove some unneeded floor / rounds.
Use more vector math in Caledonian Meadows, Oasis and Wild Lake, refs #4845.

comment:6 by elexis, 5 years ago

In 20973:

Pass a vector to createStoneMineFormation, refs #4992.

On India,
remove another mysterious lake size area factor on India, refs #4958,
increase the lakesize on small maps and
simplify constraints.

comment:7 by elexis, 5 years ago

In 20974:

Pass vectors to the ChainPlacer instead of the components individually, refs #4992, #4845.
Support non-integer numbers.

comment:8 by elexis, 5 years ago

In 20977:

Return vectors instead of objects with x and z property for all Placers and Painters, refs #4992, #4845.

Create the vectors sooner, so that the conditions can use them eventually too and since the loops might be replaced with vector getters.
Fix missing comma in Deep Forest rP20971.
No measurable performance decline was noticed.

comment:9 by elexis, 5 years ago

In 20978:

Use vectors in Constraints, refs #4992.

comment:10 by elexis, 5 years ago

In 20979:

Use vectors for inMapBounds, refs #4992.

comment:11 by elexis, 5 years ago

In 20980:

Use vectors in the Terrain prototype, refs #4992.

comment:12 by elexis, 5 years ago

In r20983: Use vectors for getHeight and remove the global proxy, refs #4992.

comment:13 by elexis, 5 years ago

In 20988:

Use vectors for setTexture, refs #4992.

Simplify duplicate Caledonian Meadows and Wild Lake height-based texture painting by using for-of loops, texture setter and vectors, refs #4845, #4998.
Allow setTexture to write to impassable tiles as reported by FeXoR some time ago, refs #4245.

comment:14 by elexis, 5 years ago

In 20993:

Use vectors for validT and rename it to validTile, refs #4992.

comment:15 by elexis, 5 years ago

In 20994:

Use vectors for cornerHeight, getExactHeight, validH and rename the latter to to validHeight, refs #4992.

Use the height getter and setter rather than directly operating on the prototype member, which also simplifies the code.

comment:16 by elexis, 5 years ago

In 21021:

Change placeObject, placeStartingWalls, wall builder library and wall demo to use vectors, refs #4845, #4992.

comment:17 by elexis, 5 years ago

In 21025:

Stop identifying TileClasses by a customly defined TileClassID, but just identify the prototype instance directly, refs #4804, rP9096.
Delete hence unneeded validClass, getTileClass, addToClass and removeFromClass.

Use vectors for the TileClass add and remove function, refs #4992.
Use createArea call for addCivicCenterAreaToClass.

comment:18 by elexis, 5 years ago

In 21026:

Cleanup TileClass prototype and use vector arguments for countInRadius, countMembersInRadius, countNonMembersInRadius, refs #4992.

comment:19 by elexis, 5 years ago

Milestone: BacklogAlpha 23
Owner: set to elexis
Priority: Nice to HaveShould Have

comment:20 by elexis, 5 years ago

Resolution: fixed
Status: newclosed

In 21069:

rmgen random placement and Entity instantiation refactoring, fixes #4992.

ChainPlacer, ClumpPlacer, SimpleObject receive the vectors that are in place everywhere already, refs #4845.
Add public setCenterPosition to CenteredPlacer and Group rather than writing private properties of the prototypes.
ChainPlacer and ClumpPlacer simplifications, deduplication and renames, refs #4805.

Replace placeObject global with RandomMap placeEntity members, refs #4804.
Split to placeEntityPassable / placeEntityAnywhere, as well as validTilePassable / validTileAnywhere to more cleanly distinguish actor and casual entity placement.
No more does SimpleObject create Entity instances and register entityIDs if they are never placed.
Removes the map global reference from the Entity constructor, refs #4964.
By definition of what is passed to the engine, an Entity has an ID and position, so keep it impossible to create Entities without IDs.

Implement randomPositionOnTile so that there aren't different implementations thereof, including unintented ones as in ardennes_forest.js in rP21021.
On Caledonian Meadows, remove unused pathplacing code, to be superseded by #4368.
On Schwarzwald, delete unused startLocations following rP20864.
On Latium, replace complicated duplicated hardcoded fish location computation with a simple HeightConstraint, refs #4960.

comment:21 by elexis, 5 years ago

In 21300:

Ambush bluffs rework.
Remove ugly large circle patterns around the playerbase on Ambush, fixes #4993.
To ensure passability, create ramps from the playerbase to the bluffs.

Change the circular player avoidance to a ChainPlacer generating more heterogenous pattern.
Use vectors in rmgen2 bluffs creation and simplify equations, refs #4992.
Don't turn inaccessible bluffs to plateaus but don't place them until it is certain they are passable.

Increase minimum distance from the playerbase to the mapcenter by picking different distance values per playerbase pattern in g_PlayerbaseTypes.
Attempt to improve bluffs performance by avoiding bluffIgnore by 0 instead of bluff by 12, refs #5011.
Implement AdjacentToAreaConstraint and deleteTerrainEntity.
Delete createBoundingBox and use getBoundingBox, refs #4947, #4805.
Delete fadeToGround and nextToFeature and use conventional createArea calls with the SmoothingPainter of rP21175, refs #5027.
Paint bluff cliffs slightly more accurately using the SlopeConstraint from rP21085, refs #5004.

Note: See TracTickets for help on using tickets.