ilmola / generator

A procedural geometry generation library for C++11
GNU Lesser General Public License v2.1
211 stars 26 forks source link

msvc 2015 x64 compilation issue #20

Closed qtnext closed 7 years ago

qtnext commented 8 years ago

Hi,

we are trying to build your lib (with glm) on Windows with msvc 2015 (x64) and we have the following issue
Error C2075 'generator::BezierMesh<4,4>::::p' : array initialization needs curly braces

in this part : /// @param p Control points /// @param segments Number of subdivisions along each axis explicit BezierMesh( const gml::dvec3 (&p)[D1][D0] = {}, const gml::uvec2 segments = {16u, 16u} ) : mParametricMesh{

        // Lambda capture the array by value.
        [p] (const gml::dvec2& t) {
            MeshVertex vertex;

            vertex.position = gml::bezier2(p, t);

            gml::dmat2x3 J = gml::bezier2Jacobian<1>(p, t);
            vertex.normal = gml::cross(J[0], J[1]);

            // If the normal was zero try a again near by.
            const double e = std::numeric_limits<double>::epsilon();
            if (dot(vertex.normal, vertex.normal) < e) {
                J = gml::bezier2Jacobian<1>(p, t + 10.0 * e);
                vertex.normal = gml::cross(J[0], J[1]);
            }
            vertex.normal = gml::normalize(vertex.normal);

            vertex.texCoord = t;

            return vertex;
        },
        segments
    }

{ }
JesseTG commented 8 years ago

What happens if you just pass by reference?

ilmola commented 8 years ago

I suspect that msvc does not support the "= {}" syntax for the default argument. Does it compile if you just remove the default value "= {}" from the argument "p" (from BezierMesh.hpp and from BezierShape.hpp)?

ilmola commented 8 years ago

After trying this with an online compiler it seems that this is caused by a by bug in msvc not being able to capture arrays by value.

Does this branch compile:

https://github.com/ilmola/generator/tree/wrap_array

(it will replace capture with a manual copy)

qtnext commented 7 years ago

thanks... compilation is ok :) ...We can start to works with your lib :)

2016-10-21 22:28 GMT+02:00 qt next qtnext@gmail.com:

thanks for your time .. It test this tomorrow :)

2016-10-21 19:34 GMT+02:00 Markus Ilmola notifications@github.com:

After trying this with an online compiler it seems that this is caused by a by bug in msvc not being able to capture arrays by value.

Does this branch compile:

https://github.com/ilmola/generator/tree/wrap_array

(it will replace capture by manual copy)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ilmola/generator/issues/20#issuecomment-255431007, or mute the thread https://github.com/notifications/unsubscribe-auth/AV5WZ-Xcee0FHuoGRUER32muDUGmhDk9ks5q2PeMgaJpZM4KcHcG .

qtnext commented 7 years ago

thanks for your time .. It test this tomorrow :)

2016-10-21 19:34 GMT+02:00 Markus Ilmola notifications@github.com:

After trying this with an online compiler it seems that this is caused by a by bug in msvc not being able to capture arrays by value.

Does this branch compile:

https://github.com/ilmola/generator/tree/wrap_array

(it will replace capture by manual copy)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ilmola/generator/issues/20#issuecomment-255431007, or mute the thread https://github.com/notifications/unsubscribe-auth/AV5WZ-Xcee0FHuoGRUER32muDUGmhDk9ks5q2PeMgaJpZM4KcHcG .

qtnext commented 7 years ago

Do you wants that we test this ? (if yes .. it don't works too:()

/// @param p Control points /// @param segments Number of subdivisions along each axis explicit BezierMesh( const gml::dvec3(&p)[D1][D0] /= {}/, const gml::uvec2 segments = { 16u, 16u } ) : mParametricMesh{ // Lambda capture the array by value. [p](const gml::dvec2& t) { MeshVertex vertex;

vertex.position = gml::bezier2(p, t);

gml::dmat2x3 J = gml::bezier2Jacobian<1>(p, t); vertex.normal = gml::cross(J[0], J[1]);

// If the normal was zero try a again near by. const double e = std::numeric_limits::epsilon(); if (dot(vertex.normal, vertex.normal) < e) { J = gml::bezier2Jacobian<1>(p, t + 10.0 * e); vertex.normal = gml::cross(J[0], J[1]); } vertex.normal = gml::normalize(vertex.normal);

vertex.texCoord = t;

return vertex; }, segments } { }

2016-10-20 17:51 GMT+02:00 Markus Ilmola notifications@github.com:

I suspect that msvc does not support the "= {}" syntax for the default argument. Does it compile if you just remove the default value "= {}" from the argument "p" (from BezierMesh.hpp and from BezierShape.hpp)?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ilmola/generator/issues/20#issuecomment-255146633, or mute the thread https://github.com/notifications/unsubscribe-auth/AV5WZ30Y0LCQjjpK_Q3xbTOArzHmNTEUks5q143sgaJpZM4KcHcG .

ilmola commented 7 years ago

Fix branch merged to master.

qtnext commented 7 years ago

Hi Thanks ... it compile now on msvc 2015 and xcode 8.0 ... and works very Well on mac and on windows :)

Envoyé depuis mon smartphone Samsung Galaxy. -------- Message d'origine --------De : Markus Ilmola notifications@github.com Date : 26/10/2016 19:15 (GMT+01:00) À : ilmola/generator generator@noreply.github.com Cc : qtnext qtnext@gmail.com, Author author@noreply.github.com Objet : Re: [ilmola/generator] msvc 2015 x64 compilation issue (#20) Closed #20.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/ilmola/generator","title":"ilmola/generator","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/ilmola/generator"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Closed #20."}],"action":{"name":"View Issue","url":"https://github.com/ilmola/generator/issues/20#event-837399952"}}}