Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Curved Minecart Tracks  (Read 2248 times)

Reelya

  • Bay Watcher
    • View Profile
Re: Curved Minecart Tracks
« Reply #15 on: September 22, 2018, 10:36:05 am »

Yup, i didn't know about those files, but it's handy.

This looks like some pretty simple modeling where things are point masses. Having individual fields for XYZ location, velocity and acceleration isn't that great. In a proper physics simulation there would be at least one matrix or quaternion in here to account for object location and orientation in space.

Also note that parabolic is a flag. Which means it exists to be turned on or off. We have no direct evidence that this is being used all the time or whether it's placeholder stuff that's not active.
« Last Edit: September 22, 2018, 10:51:24 am by Reelya »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Curved Minecart Tracks
« Reply #16 on: September 22, 2018, 11:38:28 am »

It's used specifically in minecarts, has existed since 0.34.08.

EDIT: Oh, I missed the patch notes from 0.34.09:

Code: [Select]
All flying units use new minecart parabolic flight paths
turns out i've been mistaken about that for 6 years

EDIT 2: Yeah, the devlog from 4/20/2012 was the first one mentioning them:

Code: [Select]
The struck units move in parabolic arcs now (instead of the old fly straight then fall straight down).
« Last Edit: September 22, 2018, 11:41:10 am by Putnam »
Logged

Miles_Umbrae

  • Bay Watcher
    • View Profile
Re: Curved Minecart Tracks
« Reply #17 on: September 24, 2018, 05:50:16 pm »

Question: Isn't movement, spatial occupation, and graphical representation three distinct and separate parts of the games coding?
Also: Isn't movement through a one-square space like for example a door subdivided into 10 on either of the X, Y & Z axes?
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Curved Minecart Tracks
« Reply #18 on: September 25, 2018, 07:25:29 pm »

position and movement are 1:1 with graphics, movement is not "move 1/n tiles every tick" but "move to this tile in n ticks"

Reelya

  • Bay Watcher
    • View Profile
Re: Curved Minecart Tracks
« Reply #19 on: September 25, 2018, 07:35:09 pm »

Which also allows far more efficiency. For example, if you move n-distance every tick, then every object needs to be moved on every tick, and you need to run real-time collision detection against 3D bounding boxes for every item in the scene against every other item in the scene. 100 world items means potentially 10000 collision detections per frame, or applying a complex graph system to reduce the number of checks.

Whereas what Putnam is describing is just much much faster to compute. You know that a particular object will move in 300 ticks, so you just make a list of all active things. For example, if there are 1000 objects but nothing is going to happen for 200 ticks, you're not running 200 x 1000 update functions for each object for those 200 ticks, you just look "oh, the next thing moves in 200 ticks, so advance the clock by 200 then move that object. Then, work out when that object moves again, and insert it back into the queue wherever it belongs. Now, what's next to move?" Also, things being 100% in or out of a cell means you can just have a true/false flag for whether there's anything in a tile, and you can maintain a list of stuff there for each tile that needs one.

Miles_Umbrae

  • Bay Watcher
    • View Profile
Re: Curved Minecart Tracks
« Reply #20 on: September 26, 2018, 03:42:50 pm »

With spatial occupation I meant how much of a square an entity occupies.
For example, a dog takes up less of a square than a dwarf or cow does.
Several dwarves can pass by each other in the same square simultaneously.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Curved Minecart Tracks
« Reply #21 on: September 26, 2018, 03:51:22 pm »

That's... totally wrong. Occupancy rules are as follows:

1. Any amount of units that are lying down can occupy a tile.
2. Exactly one unit that is standing can occupy a tile.

These are the only rules. Size has nothing to do with it. You can fit 100 dragons in a tile, but all of them have to be lying down except one.

Miles_Umbrae

  • Bay Watcher
    • View Profile
Re: Curved Minecart Tracks
« Reply #22 on: September 26, 2018, 04:13:41 pm »

That's... totally wrong. Occupancy rules are as follows:

1. Any amount of units that are lying down can occupy a tile.
2. Exactly one unit that is standing can occupy a tile.

These are the only rules. Size has nothing to do with it. You can fit 100 dragons in a tile, but all of them have to be lying down except one.
Strange then that I seen several dwarves and/or animals occupy the same square a few ticks...
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Curved Minecart Tracks
« Reply #23 on: September 26, 2018, 04:41:15 pm »

All of them expect on have been lying down.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Curved Minecart Tracks
« Reply #24 on: September 27, 2018, 09:07:43 am »

That's... totally wrong. Occupancy rules are as follows:

1. Any amount of units that are lying down can occupy a tile.
2. Exactly one unit that is standing can occupy a tile.

These are the only rules. Size has nothing to do with it. You can fit 100 dragons in a tile, but all of them have to be lying down except one.
Strange then that I seen several dwarves and/or animals occupy the same square a few ticks...

Odd indeed, since what I said was determined by memory hacking and is relied upon for the DFHack teleport script, which I wrote.

Code: [Select]
local unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16]
 local newoccupancy = dfhack.maps.getTileBlock(pos).occupancy[tonumber(pos.x)%16][tonumber(pos.y)%16]
 if newoccupancy.unit then
  unit.flags1.on_ground=true
 end
 unit.pos.x = tonumber(pos.x)
 unit.pos.y = tonumber(pos.y)
 unit.pos.z = tonumber(pos.z)
 if not unit.flags1.on_ground then unitoccupancy.unit = false else unitoccupancy.unit_grounded = false end

As you can see, there are only two flags that determine unit occupancy: "unit" and "unit_grounded". If the tile occupancy's "unit" flag is set, no unit entering that tile can stand in it. This is the only rule here.
Pages: 1 [2]