JCash / defold-terrain

A simple terrain engine
5 stars 1 forks source link

Does not build on windows + missing asset #1

Open subsoap opened 3 years ago

subsoap commented 3 years ago

The green.png is not included with the public repo

2021-03-11 23_05_47-defold-terrain - Defold Editor 2 0

/defold-terrain/src/loader_file.cpp
    Line 1: 'dlib/log.h' file not found
#include <dlib/log.h>
         ^~~~~~~~~~~~

/defold-terrain/src/terrain.cpp
    Line 55: expected body of lambda expression
    for (int i = 4; i--; ) near[i]      = mat[i][3] + mat[i][2];
                                        ^
    Line 56: expected body of lambda expression
    for (int i = 4; i--; ) far[i]       = mat[i][3] - mat[i][2];
                                        ^
    Line 307: unused variable 'wx' [-Wunused-variable]
    float wx = patch->m_XZ[0];
          ^
    Line 308: unused variable 'wz' [-Wunused-variable]
    float wz = patch->m_XZ[1];
          ^
    Line 313: unused variable 'world_size' [-Wunused-variable]
    uint32_t world_size = 65536;
             ^
    Line 325: unused variable 'u0' [-Wunused-variable]
            float u0 = x * oo_patch_size_f;
                  ^
    Line 326: unused variable 'u1' [-Wunused-variable]
            float u1 = (x+1) * oo_patch_size_f;
                  ^
    Line 327: unused variable 'v0' [-Wunused-variable]
            float v0 = z * oo_patch_size_f;
                  ^
    Line 328: unused variable 'v1' [-Wunused-variable]
            float v1 = (z+1) * oo_patch_size_f;
                  ^
    Line 370: unused variable 'patch_size' [-Wunused-variable]
    int patch_size = GetPatchSize(0);
        ^
    Line 677: unused variable 'camera_moved' [-Wunused-variable]
        bool camera_moved = camera_diffx!=0 || camera_diffz!= 0;
             ^
    Line 777: use of undeclared identifier 'M_PI'
        int octant = int( 8 * a / (2*M_PI) + 8.5f ) % 8;
                                     ^
subsoap commented 3 years ago

Different errors when testing bundling for macOS / Linux

2021-03-11 23_10_08-defold-terrain - Defold Editor 2 0

The final comma is the problem

2021-03-11 23_12_34-JSONLint - The JSON Validator

Fixed buffer files meshes.zip

But bundling is still not working 2021-03-11 23_14_50-defold-terrain - Defold Editor 2 0

subsoap commented 3 years ago

Changing

include <dlib/log.h>

To

include <dmsdk/dlib/log.h>

Makes bundling for macOS work

subsoap commented 3 years ago

I don't yet understand what to change here for building on Windows to work

/defold-terrain/src/terrain.cpp
    Line 59: expected body of lambda expression
    for (int i = 4; i--; ) near[i]      = mat[i][3] + mat[i][2];
                                        ^
    Line 60: expected body of lambda expression
    for (int i = 4; i--; ) far[i]       = mat[i][3] - mat[i][2];
    for (int i = 4; i--; ) near[i]      = mat[i][3] + mat[i][2];
    for (int i = 4; i--; ) far[i]       = mat[i][3] - mat[i][2];
subsoap commented 3 years ago

Weird, deleting those two lines entirely allows Windows to build and run.

subsoap commented 3 years ago

I also had to add this to terrain.cpp

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
subsoap commented 3 years ago

It seems to just be complaining about the words near / far, changing them to left/right on those lines works to compile too. No clue from me.

JCash commented 3 years ago

Heh, you're brave trying to build this repo :)

For M_PI (MSDN)

define _USE_MATH_DEFINES // for C

include

Not sure why it finds the 'dlib/log.h` for me, but it's probably because I use a local build server.

And, the texture shouldn't be used at all anymore, I'm going to delete the models referencing those.

The near/far thing I'm not sure about. Since I don't use that function at all yet, we can comment it out.

subsoap commented 3 years ago

2021-03-12 02_14_52-defold-terrain

Profiler screen from my machine. :)

JCash commented 3 years ago

You need to use the 1.2.181 alpha build

subsoap commented 3 years ago

Silky smooth now!

2021-03-12 03_39_59-defold-terrain

subsoap commented 3 years ago

When looking around it's silky smooth in 1.2.181 alpha and while no chunks are being loaded/generated, but it does hang while chunks are being loaded/generated.

https://www.youtube.com/watch?v=LYkHSRXU5Oo

JCash commented 3 years ago

Hard to tell from that profile. Better to list a single frame in the web profiler. My guess it's the dmGraphics::SetVertexData the actual upload of the vertex buffer. The patches are at a very high detail right now, and are not compressed either. Interesting though that on my iMac it runs smooth all the way.

subsoap commented 3 years ago

I adjusted controller.script to auto move fast and tried to capture a big frame time. If you want me to test anything I can.

function update(self, dt)
    self.input_move.z = self.input_move.z + 100

My CPU is quite old now and it's about time I get a new computer but at the same time I feel it's useful to hang onto it because then it's a way to quickly know in our own projects if something is very wrong. My brother on the other hand has a brand new build and we've had similar situations where it runs perfectly on his but I notice issues so we work to improve it until it works fine on mine.

2021-03-12 04_36_40-Dynamo Profiler

2021-03-12 04_38_42-Dynamo Profiler

2021-03-12 04_40_38-Dynamo Profiler 2021-03-12 04_40_46-Dynamo Profiler

subsoap commented 3 years ago

Tried to test HTML5 build Chrome Version 89.0.4389.82

2021-03-12 04_45_14-Window

Looks like a thread issue, but shouldn't WebAssembly Threads be working now / again since a while or is this something else?

subsoap commented 3 years ago

https://dzone.com/articles/webassembly-threads-in-firefox

JCash commented 3 years ago

Well, this repo is by far not done, and I havent tested it on any platform, so there are bound to be issues.

We currently have no official thread support on web (js or wasm). Hopefully we can get to it soon.