Comments (9)
There are no const modifiers on operators
no match for ‘operator+’ (operand types are ‘const openage::coord::tile’ and ‘const openage::coord::tile_delta’)
from openage.
Parameters of those binary operators should be changed to const references.
from openage.
could someone explain the pain of the current implementation, and how would the paradisiac version be like?
from openage.
By "someone" you probably mean @mic-e as he wrote the coord
system in the first place.
from openage.
The pain with the current version is that it's pretty unmaintainable and extremely hard to read because it uses preprocessor #defines
and #includes
in an unconventional way to produce the required .cpp
and .h
files for the absolute and delta classes for each coordinate system, including all of their overloaded operators.
Writing all code by hand would be an option, though it would create immense redundancy. It also would make adding a new coordinate system pretty hard.
An ideal solution would have instruction files of some kind ==
in the coord
folder, and have a python code generator module use them to create the full .h
and .cpp
files from them.
from openage.
I'm planning to implement this. There's not much that changes between the different types, so the following information would be enough:
namespace = coord;
scalar_type = phys2;
members = ne, se;
body = {
phys3 to_phys3(phys_t up = 0) const;
tile to_tile() const;
phys2_delta get_fraction() const;
};
delta_body = {
phys3_delta to_phys3(phys_t up = 0) const;
//allowing conversions of phys deltas to tile deltas isn't such a great
//idea. you never know whether a phys change of 0.9 will _actually_
//change the tile.
};
This example would be something like phys2.scalar
, which would then generate phys2.h
with the structs and all operations for the phys2
and phys2_delta
types.
Some loose ends:
- It would be nice to be able to define these files for example in the
cpp/console
folder, with the correct namespace generated. At the momentcpp/coords
also contains some types for the console, so it would be nice to separate them. - Some of the types have a hash function defined, but
phys3
only uses the first two values in the hash. Can we generalize this, or otherwise just specify which members are to be used in the hash?
from openage.
A few thoughts that I had about the coord system: (for the record, i just extracted the following from a 2000 lines-xmpp-conversation):
- Constraint: conversions should be very fast.
- Eliminate the global state (e.g. scroll position) by inheritance:
- Every component having some coord state inherits from a coord base class.
- This class provides the state members (the new
struct coord_state
) and functions for modifying the state. - Calling these will only modify the inherited state members, global state is purged.
- All coordinates instanced have to be bound to some coordinate system, where they can access the state (e.g. current camera position etc).
- This means one coordinate has an absolute position in this system. When converting to other systems, the state of the relevant reference systems are used in the transformation calculation.
- The delta coordinates don't need that binding, as they are just relative values for one reference system (can be applied to other deltas, like a vector, or to an absolute position within one ref system).
- This way the conversion can still be done conveniently as the .to_whatever() just makes use of the initially-remembered coordinate system it was bound to.
- When creating new coordinates, they could be generated by a factory of the the respective coordinate base class (the one defining the coordinate space and state). This way generated coordinates are bound to that space without passing the space to the new coordinate's constructor all the time.
- example:
- the
r
could e.g. be the scroll state of the minimap, or the view center of the main game view. - code:
- the
struct phys3 {
phys_t ne, se, up;
CoordReference *r;
to_camgame() {
// of course that's not sufficient but just an example:
return camgame{r->state + ne + se + up};
}
}
- One could even perform a reference transformation, by defining a vector etc between two reference spaces, the coordinates can be translated between two bases.
- This is basically a vector space with base transformations.
- All the transformations between systems are performed by applying operations to coordinates that rely on some state that is kept by members of e.g. engine, minimap, terminal, etc.
- To create a new coordinate, you have to fetch it at the reference system (so that the coord is bound to it). The reference system is a factory that tracks state and can produce coordinates that are linked to it.
from openage.
Another attempt: #662
from openage.
Closed through #975.
from openage.
Related Issues (20)
- CLI parameter for engine start mode
- "error: ‘Dict’ is not a member of ‘nyan’" during build HOT 7
- Can't build with clang, error: "jthread is supported now, remove custom definition" HOT 4
- Asset conversion issue, AttributeError: 'NoneType' object has no attribute 'readable' HOT 6
- Adding PR/ISSUE Templates for this repo HOT 7
- Asset path type is incorrectly used HOT 5
- error: Couldn't find qml root folder HOT 15
- Test fail when building with GCC 13.2.1 HOT 10
- Error launching game, uncaught exception(s) HOT 25
- openage game: error: the following arguments are required: --modpacks HOT 4
- Running Error on Mac osx 13.4(Macbook M1 Pro ARM architecture) HOT 1
- FATAL: terminate has been called uncaught exception std::exception of type std::__1::system_error: thread::join failed: Invalid argument HOT 2
- Multiple cmake issues when trying to build HOT 4
- Submission to Steam HOT 2
- OpenGL error when launching on Wayland HOT 11
- CMake can't find toml11 on Linux Mint 21.2 HOT 4
- Errors after the new PR merged HOT 3
- Link on website https://openage.sft.mx/ to windows packages is a broken link HOT 2
- Windows Build: Python Command Requiring --modpacks Argument HOT 3
- Asset conversion stalls on media conversion HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openage.