samdauwe / BabylonCpp

A port of Babylon.js to C++
Apache License 2.0
284 stars 38 forks source link

Make headerless sample #50

Closed pthom closed 4 years ago

pthom commented 4 years ago

Hello,

This PR adds several things:

It also adds a useful script make_headerless_sample.py

This scripts helps transitionning to headerless examples since it does most of the job.

Usage:

  1. Set filename_no_extension and sample_category at the end of the file

filename_no_extension = "pick_and_play_animation"
sample_category = "Animations"
make_headerless_sample(filename_no_extension, sample_category)
  1. Run the python script

Here is what it does

After that, the example is now almost ready to be committed (you still need to test it :-)

def make_headerless_sample(filename_no_extension, sample_category):
    h_full_path = compute_header_full_path("/" + filename_no_extension + ".")
    cpp_full_path = compute_cpp_full_path("/" + filename_no_extension + ".")
    if h_full_path is not None:
        h_include_path = compute_header_include_path(h_full_path)

    if h_full_path is not None:
        remove_all_includes(h_include_path)
        remove_header_guard(h_full_path)
        repair_see_links(h_full_path)
        move_header_code_to_cpp(h_full_path, cpp_full_path)

    add_include_samples_index_to_cpp(cpp_full_path)
    register_example_scene(cpp_full_path, sample_category)
samdauwe commented 4 years ago

Hello Pascal,

Thanks for the script!

Yesterday, I manually made all gltf and babylon loading examples headerless. I could update 40 examples in one hour, I was doing the same operation over and over again. This script should help saving some hours of manually updating the files.

I noticed the Windows build was broken because of a name clash, the camera gltf scene was renamed so it would work with your sample indexing script but the camera scene already existed. Strange that this worked with gcc. I also fixed the annotations in that sample.

Are you currently running the _make_headerlesssample.py script on other examples or can I continue with making the examples headerless? We can also divide the work if you want to continue with it.

Thanks, Sam