GithubHelp home page GithubHelp logo

bb1950328 / bricksim Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 222.78 MB

LDraw™ editor and simulator

Home Page: https://BrickSim.org

License: GNU General Public License v3.0

CMake 0.56% C++ 98.94% GLSL 0.12% Shell 0.13% Python 0.17% C 0.03% GSC 0.02% Dockerfile 0.03% PowerShell 0.01%
lego lego-technic lego-block opengl3 cpp ldraw ldraw-editor

bricksim's Introduction

bb1950328

bricksim's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

bricksim's Issues

Add more unit tests

Basically the title. All components that can be used without too much overhead should be tested.

Error handling / exceptions

Error handling currently is very inconsistent. The idea is to create two custom exception types: one which means that the current task failed and the program can safely continue and another which means that the program must exit. The controller can display a error message when a task thread threw an exception.

Transform gizmo

Display a transform gizmo to translate and rotate things directly inside the 3D view.
The renderer has to render the meshes in layers to accomplish this.

Automatic self-update

  • Check if there's a new release on GitHub at startup
  • Add a config variable to control check frequency
  • Add a cache variable to save last check
  • If a new release is found, show it to the user with the release notes and the following options:
    • Install now
    • Ask on next startup
    • Ask on exit
    • Skip this version
  • If the user chooses to install the new version, download it and somehow replace the executable or run the installer

Update file list when parts library changed

When the parts library was changed (compare last modification time of directory) the file list should be reloaded. Maybe it's possible to only partially reload it to save time.

Small Ideas / TODOs

This is just a issue to collect ideas and TODOs which aren't big enough for a dedicated issue

  • split util into multiple files to reduce recompilation times
  • replace util::startsWith with std::string::starts_with, same for endsWidth
  • use vectors or arrays in ldr::FileElement subclasses instead of many single floats (use union so scalars are still accessible directly)
  • reformat CMakeLists.txt and sort all source files
  • Improve text in "About" window
  • some functions in util.cpp can probably be templated (mostly functions with glm::vec parameters)
  • move all scripts to the scripts folder (except setup_workspace.sh)
  • go back to OpenGL 3.3 (only functions in e655309d7efb4 use glDrawElementsInstancedBaseInstance which requires 4.2)
  • make imgui use glm::vec types (this might be helpful)
  • check if TriangleVertex.position can be made vec3 and then convert to vec4 in shader (saves 14% VRAM)
  • create ClangFormat config
  • check how much faster fast_float library is
  • fix min enclosing ball and selection box calculation
  • add option to delete vertex data from RAM after copying to VRAM
  • add revision in etree::Node instead of one global bool elementTreeChanged
  • find out why model load popup is open longer than model open time in log
  • try to make ldr file parsing faster by using string_view instead of substring
  • try to make string to int parsing faster in ldr files reading using this
  • two elements with the same name in element tree cause problems with expanding/collapsing
  • Part Palette: make margins around thumbnails smaller
  • Include guard in resources.h
  • find out why I have to transpose all matrices when passing to etree::Node::setRelativeTransformation
  • suppress all compiler warnings from dependencies
  • add function to replace the "~Moved to XXX" parts with their targets
  • execute chmod +x in mac installer build job like here
  • reduce memory usage when initializing cache db (deleting the files from the repo cache after getting the meta info might already be enough)
  • fix progress numbers when downloading parts library
  • Dock 3D View window somewhere after opening file
  • Add a function to spin the model around until the user clicks inside the 3D view (also useful for performance testing)
  • Try to convert the selection buffer to uint32 to save memory
  • Orientation cube texture is loaded six times
  • bricksim::ldr::file_repo::FileRepo::getAllFilesOfCategory and some related functions can return const reference instead of value
  • Update Thumbnails of Submodels in Part Palette

split/merge part

Idea:

  1. User selects two 1x1 bricks which are positioned side-by-side.
  2. User starts the action
  3. If there are multiple possibilities, the user gets displayed a prompt with small images of each possibility and he can use the mouse or the number keys to choose one
  4. Bricks get replaced

A challenge is to get the information which bricks can be replaced through which. The easiest way is hardcoding. This would work for:

  • n*m bricks
  • bricks with pinholes
  • n*m plates
  • n*m tiles
  • technic liftarms
    • by length (3+5+3 = 11)
    • two thin to one thick
  • technic axles
  • panels
  • 3plate=1brick
  • corner bricks like 2357

Transform Gizmo: visual improvements

Since #2 is already taking very long, I created a new issue for this.
Currently, the transform gizmo stays visible when the user drags it around. At this time, it just blocks the view of the part being moved.
So it should disappear when the user starts a transformation. When translating in one dimension, an infinite line should appear. The line has small cubes which symbolize the snapping. When translating 2D, a grid should appear. The spacing of the grid lines is like the snapping distance.
When rotating, a circle with cubes to indicate snapping angle should appear.

The color of the lines is like the axis they are (X=red, Y=green, Z=blue)
The cubes are colored like the line they are on.

Depends on #52.

Write a user manual

As the title says, write a user manual on the website which new users can read to get to know the application. But also existing users should find information about a specific thing in this manual.

Measuring tool

A tool to measure various distances can be very useful. The user selects two points and BrickSim outputs the distance between them. These points can be:

  • Edges
  • Triangles
  • Center of axle holes, studs or other circles

Algorithm to get the point under the mouse probably will be something like:

  1. Get the etree::Node under the mouse using the selection buffer
  2. Cast a ray and check for intersections of LdrTriangles or LdrLines or primitives like studs
  3. Display the currently chosen point so the user sees what he will be clicking.

And angle or area measurement can be useful too. The possibility to restrict the measuring to one or two dimensions would be nice too (for example to measure the X difference between two points without taking Y and Z into account)

replace git_stats.h

make CMake invoke update_git_statistics.h and forward the output to add_compile_definitions() so the script doesn't have to write to the source code anymore and the GitHub Actions workflow gets obsolete.

Set camera origin to part location

Line in other programs, there should be a function to set the origin of the camera to the coordinates of a part. The camera should then rotate around this part.

Inventories

The user should be able to create Inventories in BrickSim. A inventory is a map where the key is the combination of part number and color and the value is a quantity. An example for an Inventory in CSV format could be:

3004;1;123
3002;4;321

Which means that the part 3004 in color 1 is available 123 times and the part 3002 in color 4 is available 321 times.

The following features should be supported:

  • Save inventories in config.db
  • Add GUI to create a new Inventory
  • Add GUI to view and edit an inventory
    • with part thumbnails in correct color
    • with one thumbnail per part for all colors and colored numbers for quantities in each color and also total quantity for that part
    • Stats like total count, total weight, total price etc.
  • Import
  • Export
    • to CSV
    • to a Bricklink XML
    • to a new editor where all parts are laid out
      • all parts only once per color
      • same parts (part and color) stacked on top of each other
      • Sort by different attributes

Rewrite `config::`

Rewrite the configuration read/write code. Things to change

  • templates for the types (with conversion int -> long or double -> float for example)
  • get string from key name using a macro trick or maybe there's even something without macros
  • optional callbacks for when the value has changed while running the program -> the other values should get a info "requires restart to apply" tooltip in the config window
  • refactor config window code so simple keys do not need so much code for each one

Make round parts smoother

change the normals of triangle vertices when there is an optional line going through it. This should make rounded parts much smoother without increasing the triangle count.
Maybe there are other techniques to distinguish rounded edges from sharp edges...

Camera pan

The camera should be pannable (move up/down/left/right without rotating).

There is already some code but there's a mistake somewhere in the vector math. (CadCamera::mousePan)

Add universal keymap component

All actions from the user should be invoked through this component.
The user should be able to customize all keyboard shortcuts and also mouse events

Use Rebrickable data

Make a downloader for the Rebrickable LEGO Database and save it into cache.db.
The schema diagram is provided. Unfortunately the links to the CSV files aren't constant so the program has to scrape the HTML to get the current links. When the links change the user can be asked if he wants to download the new files.

Unoffical part library support

User can add another path to a .zip or folder of unoffical parts. If the file repository doesn't find a file in the official parts library it should also look for it in the unoffical library.

These files should also automatically be included in saved .mpd files.

Remove 32bit support

basically it is important to me that BrickSim runs on as many PCs as possible. That's why I have also created 32bit builds for Linux and Windows. However these 32bit builds often cause problems, especially the windows one. That's why I decided to remove them. This is not a decision taken lightly:

  • this article shows that in May 2021 only 0.32% of the windows users have a 32bit system.
  • the steam hardware survey of April 2021 shows that no more than 0.30% of the windows steam users do not have a 64bit operating system.
  • I couldn't find any numbers for Linux, but after reading this article I decided to keep 32bit Linux support, but remove it when it causes to big problems.

Custom Icons

In the future, I want some buttons or other things with custom icons. All icons should be saved in individual files and then baked into one big file using a script. There are two options:

Option 1: A font

When I can create a font with all the icons and then import it into ImGui correctly, This section of the Dear ImGui docs demonstrate the usage of colorful emojis so it should work. I also want to be able to use the icons somewhere else (like in a 2d_overlay) so there must be a possibility to get the texture ID of the ImGui font atlas and the UV coords of a specific glyph.
This is the preferred way.

Option 2: A separate texture

Write a python script to bake all icons into one texture, generate code for their coordinates and use it like this. Only works if there's a possibility to make a ImageButton with text and image.

Add `!TEXMAP` support

Documentation: https://www.ldraw.org/texmap-spec.html
Mesh already has support for textured triangle, so we just need to parse the !TEXMAP commands and apply the texture to the geometry.

Add a new type of node to the element tree which contains the image. The user should be able to view the image, save it to a file or replace it with another file. The image file has a name and is in some kind of repository (add binary data to the file repository, there are also some image files in the offcal parts library).

The second new node type is a texture instance. Each type of texture map (Planar/Cylindrical/Spherical) is a subclass of this type. they have the required parameters (using relativeTransformation for as many values as possible, because they can be updated through the usual instance updating process). But it seems that projecting a plane onto a cylinder or sphere isn't possible (need to do more research on that tough). So we somehow have to update the vertices. The easiest solution is to change the mesh key every time when for example the sphere radius is changed and then addToMesh is called again. The mesh key could be something like a hash of all parameters (sphere radius+angle and image name)

Integrate InstallBuilder

It looks like open source projects can get a free InstallBuilder license. Request form is here
The question now is whether InstallBuilder is easier to configure than three separate installers (one for each OS).

Save to .ldr or .mpd

Basically the title - add a save functionality so the user can save their work to a file in the LDraw format.

The code needs to go trough the element tree and convert each element back to an ldr string.
if the user opens a file we probably need to save the order of the lines so the order is not changed and the comments are preserved.

Render transparent parts

Transparent parts are much more difficult to render. Because of that, they are currently rendered as solid parts.
Tutorials: 1 2

Transformations snapping to multiples

The user should be able to configure several snapping distances like 5LDU, 10LDU and 20LDU. Then, he can choose one and the translation will only move in multiples of this distance.
Same with angles.

Status bar

An ImGui window without title bar and fixed height. It should display:

  • currently running tasks (like in IntelliJ-based IDEs)
  • hints which modifier keys do what (like in blender)
  • maybe some measurements like FPS or RAM usage

Toolbar

Depends on #50.
Create a toolbar.

  • It should be fully customizable so every user_action can be inserted.
  • Multiple Toolbars should also be supported.
  • Horizontal and vertical
  • Some special actions like a bunch of buttons for the snapping distance which can't be represented in user_actions

LXFML parsing

LXFML is the file format of the official Lego Digital Designer (LDD). Being able to parse this format would have two main advantages:

  • User can import existing creations from LDD. The files have the ending .lxf, which is a zip which contains one thumbnail and one .lxfml file.
  • The Parts Library of LDD has information the LDraw parts library doesn't have, maybe this data is useful

Links and resources:

Copy/Paste

The user should be able to cut, copy and paste selected elements. Currently not decided if the whole structure is serialized to clipboard or just the element ids or node paths. Serializing the whole element may enable copy/pasting to other processes of BrickSim or even other similar programs. For that I have to investigate what format other programs like stud.io, MLCad or LDCad use. But just copying the element ids is faster.
When the user copies a part of an LDraw file from a text editor, it would be useful if it can be pasted inside BrickSim. Or if a user copies a file in the file explorer it should be inserted on paste too.

Parts snapping to other parts

The ability to move a part around directly with the mouse can greatly speed up the build process.
Unfortunately, this is not very easy to implement, since the screen is only two-dimensional, but the part can be moved in three dimensions.
The code probably has to create a ray for every possible connection on the moving part and then go through the rest of the model and find the nearest matching connections

Figure out which license / copyright text have to be included

Before I can ship the program, I need to check for every third party lib which license they have and which text I have to include together with the program.
In the "About" window it should have a tab with all the license texts. Maybe it's required to add the text as a .txt file in the installation so I need to configure the installers so they include that file too.

Automatic Release Creation

Add a new page on the website where a human can add the release notes. It should both be readable by humans and provide a way to download them programmatically. You should be able to jump straight to a specific version with a link like bricksim.org/release-notes#v0.1.0

Add a new job to the workflow cmake_build.yml . It should depend on all createInstaller* and test* jobs and only run if a new tag like v1.2.3 was created. It should download all installers and create a new release on GitHub with all installers. When the release notes already are on the website, it should add them to the mesage of the GitHub release. Otherwise it should just add a link to the release notes on the website.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.