Giter VIP home page Giter VIP logo

rayvertex's Introduction

rayvertex

R-CMD-check R-CMD-check

Rayvertex is a 3D software renderer that allows you to generate 3D visualizations without worrying about hardware requirements or dependencies. It uses rasterization: a method that transforms meshes of triangles into an image. These meshes are specified entirely in R, and can be built either by importing external files, building scenes out of the included objects, or by constructing the mesh yourself. Rayvertex also allows the user to add any number of point lights and directional lights to a scene, and support anti-aliased lines, shadow mapping, transparent (and translucent) objects.

Rayvertex features the following:

  • Multicore tiled rendering
  • User-specified render resolution
  • Multiple material shader types:
    • Diffuse
    • Phong
    • Vertex
    • Toon (cel) shading
    • Flat shading
  • Built in shapes:
    • Sphere, cube, cylinder, segment, cone, arrow, torus, and plane
    • OBJ file support
    • mesh3d support
  • Built-in mesh transformations:
    • Rotation, translation, and scale
  • Support for normal maps, emission maps, ambient maps, and textures
  • Support for multiple point lights and directional lights with shadow mapping
  • Support for multicolor 3D line rasterization (both basic and anti-aliased)
  • Hashed material IDs for efficient memory use
  • Order-independent transparency rendering
  • Orthographic and projective cameras
  • Screen-space ambient occlusion
  • Translucent (tinted) shadows
  • Reflection Maps
  • Refractive Materials
  • Bloom
  • Tone mapping
  • Environment Maps

Meshes and scenes are specified via list structure that contains the following:

  • A list of shapes that each include:
    • An integer matrix of indices
    • (optional) An integer matrix of indices for normal values
    • (optional) An integer matrix of indices for texture coordinates
    • A vector of material IDs, indexing into the following material property list
    • A logical vector, indicating whether each vertex has normals
    • A logical vector, indicating whether each vertex has texture coordinates
  • A list of material properties. Rayvertex looks for the following:
    • Diffuse color
    • Ambient color
    • Specular color
    • Transmittance color
    • Emission color
    • Shininess (specular exponent)
    • Index of refraction (ior)
    • Dissolve (transparency)
    • Illumination model
    • Diffuse Texture Image Filename
    • Ambient Texture Image Filename
    • Emissive Texture Image Filename
    • Ambient Texture Image Filename
    • Normal Texture Image Filename
    • Diffuse Intensity
    • Ambient Intensity
    • Emissive Intensity
    • Ambient Intensity
    • Culling type
    • Shader type
    • Translucency
    • Number of Toon levels
    • Reflection Intensity
  • A 3xN matrix of vertex positions
  • A 2xN matrix of texture coordinates for each vertex
  • A 3xN matrix of normals for each vertex
  • A vector of material hashes. This can save memory by only adding a new material when it does not already exist in the object.

Rayvertex includes a series of helper functions that allow you to generate, translate, and scale meshes.

You can install rayvertex from GitHub with:

# install.packages("devtools")
devtools::install_github("tylermorganwall/rayvertex")

Example

Here, we will render a basic scene. We’ll use the built-in Cornell Box mesh to begin. Here is how the scene data is printed. Note the shapes column gives the number of triangles, whether the texture (UV)/normal coordinates are given, and the number of materials for that shape. This output also prints out overall scene information such as the bounding box and the number of shapes and unique materials.

library(rayvertex)

generate_cornell_mesh()
#> ── Scene Description ───────────────────────────────────────────────────────────
#>  Summary - Meshes: 5 | Unique Materials: 3
#>  XYZ Bounds - Min: c(-5.00, -5.00, -2.50) | Max: c(560.00, 565.00, 560.00)
#>            shapes  vertices texcoords   normals materials
#>         <ray_shp> <ray_dat> <ray_dat> <ray_dat> <ray_mat>
#> 1 <T:12|UV|N|M:1>     <8x3>     <4x2>     <6x3> <diffuse>
#> 2 <T:12|UV|N|M:1>     <8x3>     <4x2>     <6x3> <diffuse>
#> 3 <T:12|UV|N|M:1>     <8x3>     <4x2>     <6x3> <diffuse>
#> 4 <T:12|UV|N|M:1>     <8x3>     <4x2>     <6x3> <diffuse>
#> 5 <T:12|UV|N|M:1>     <8x3>     <4x2>     <6x3> <diffuse>

We can render it by passing it to rasterize_scene().

generate_cornell_mesh() |>
  rasterize_scene()
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .

Let’s add a purple sphere to the scene, and a picture of a dragon in a Cornell box to the back:

dragon_file = tempfile(fileext = ".png")
png::writePNG(rayimage::dragon, dragon_file)
mat = material_list(diffuse="purple", type = "phong", ambient="purple", ambient_intensity = 0.2)
mat_dragon = material_list(ambient_texture_location = dragon_file, ambient = "white", 
                           diffuse_intensity = 0)

generate_cornell_mesh() |>
  add_shape(sphere_mesh(position=c(300,555,555)/2, radius=80, material=mat)) |>
  add_shape(xy_rect_mesh(position = c(555/2,555/2,530), angle = c(180,0,0), 
                         scale = c(400,400,1),
                         material = mat_dragon)) |> 
  rasterize_scene(fov=40)
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` .

We can preview the material properties by printing the materials in the scene. This prints out non-default material arguments, whether a texture exists, as well provides a rough preview of the color.

scene_save = generate_cornell_mesh() |>
  add_shape(sphere_mesh(position=c(300,555,555)/2, radius=80, material=mat)) |>
  add_shape(xy_rect_mesh(position = c(555/2,555/2,530), angle = c(180,0,0), 
                         scale = c(400,400,1),
                         material = mat_dragon))

print(scene_save$material)
#> [[1]]
#> [[1]][[1]]
#> • rayvertex_material
#>  type: diffuse
#>  diffuse: #1f7326   
#>  ambient: #1f7326   | intensity: 0.2
#> 
#> 
#> [[2]]
#> [[2]][[1]]
#> • rayvertex_material
#>  type: diffuse
#>  diffuse: #a60d0d   
#>  ambient: #a60d0d   | intensity: 0.2
#> 
#> 
#> [[3]]
#> [[3]][[1]]
#> • rayvertex_material
#>  type: diffuse
#>  diffuse: #bababa   
#>  ambient: #bababa   | intensity: 0.2
#> 
#> 
#> [[4]]
#> [[4]][[1]]
#> • rayvertex_material
#>  type: diffuse
#>  diffuse: #bababa   
#>  ambient: #bababa   | intensity: 0.2
#> 
#> 
#> [[5]]
#> [[5]][[1]]
#> • rayvertex_material
#>  type: diffuse
#>  diffuse: #bababa   
#>  ambient: #bababa   | intensity: 0.2
#> 
#> 
#> [[6]]
#> [[6]][[1]]
#> • rayvertex_material
#>  type: phong
#>  diffuse: #a020f0   
#>  ambient: #a020f0   | intensity: 0.2
#> 
#> 
#> [[7]]
#> [[7]][[1]]
#> • rayvertex_material
#>  type: diffuse
#>  diffuse: #cccccc   | intensity: 0.0
#>  ambient: #ffffff   
#>  ambient_texname: /var/folders/19/j71hqsgx1jjg5kb0nxf58b200000gn/T//RtmpZ5TJIk/file114c8663b0577.png |  File exists!

Now, the ceiling of the Cornell Box is blocking the directional light. Let’s remove it.

generate_cornell_mesh(ceiling=FALSE) |>
  add_shape(sphere_mesh(position=c(555,555,555)/2, radius=80, material=mat)) |>
  rasterize_scene()
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .

Let’s add a cylinder and a platform to the bottom of our sphere.

mat2 = material_list(diffuse="grey80", ambient="grey80", ambient_intensity = 0.2)

generate_cornell_mesh(ceiling=FALSE) |>
  add_shape(sphere_mesh(position=c(555,555,555)/2, radius=80, material=mat)) |>
  add_shape(segment_mesh(start=c(555/2,0,555/2),end=c(555/2,196,555/2), 
                         radius=30, material=mat2)) |>
  add_shape(cube_mesh(position=c(555/2,555/2-90,555/2), 
                      scale=c(160,20,160),material=mat2)) |>
  rasterize_scene()
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .

Now let’s change the angle of the directional light so it’s angled from the front :

generate_cornell_mesh(ceiling=FALSE) |>
  add_shape(sphere_mesh(position=c(555,555,555)/2, radius=80, material=mat)) |>
  add_shape(segment_mesh(start=c(555/2,0,555/2),end=c(555/2,196,555/2), 
                         radius=30, material=mat2)) |>
  add_shape(cube_mesh(position=c(555/2,555/2-90,555/2), 
                      scale=c(160,20,160),material=mat2)) |>
  rasterize_scene(light_info = directional_light(c(0.4,0.2,-1)))
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .

And let’s add all the other basic mesh shapes included in the package (including the included OBJ file and the humface mesh3d object from the Rvcg package):

library(Rvcg)
data(humface)

cols = hsv(seq(0,1,length.out=6))

mats = list()
for(i in 1:5) {
  mats[[i]] = material_list(diffuse=cols[i], ambient=cols[i], type="phong",
                            ambient_intensity = 0.2)
}

generate_cornell_mesh(ceiling=FALSE) |>
  add_shape(sphere_mesh(position=c(555,555,555)/2, radius=80, material=mat)) |>
  add_shape(segment_mesh(start=c(555/2,0,555/2),end=c(555/2,196,555/2),
                         radius=30, material=mat2)) |>
  add_shape(cube_mesh(position=c(555/2,555/2-90,555/2),
                      scale=c(160,20,160),material=mat2)) |>
  add_shape(torus_mesh(position=c(100,100,100), radius = 50, ring_radius = 20,
                       angle=c(45,0,45),material=mats[[1]])) |>
  add_shape(cone_mesh(start=c(555-100,0,100), end=c(555-100,150,100), radius = 50,
                      material=mats[[2]])) |>
  add_shape(arrow_mesh(start=c(555-100,455,555-100), end=c(100,455,555-100),
                       radius_top = 50, radius_tail=10, tail_proportion = 0.8,
                       material=mats[[3]])) |>
  add_shape(obj_mesh(r_obj(), position=c(100,200,555/2), angle=c(-10,200,0),
                     scale=80,material=mats[[4]])) |>
  add_shape(mesh3d_mesh(humface, position = c(555-80,220,555/2),scale = 1,
                        material=mats[[5]],angle=c(0,180,-30))) |>
  rasterize_scene(light_info = directional_light(c(0.4,0.2,-1)))
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .

We can also draw shapes with toon shading:

set.seed(1)
col = hsv(runif(1))
scene = sphere_mesh(position=runif(3),
                    material=material_list(diffuse=col, type="toon",toon_levels = 3, 
                                           toon_outline_width = 0.025,
                                           ambient=col,ambient_intensity=0.2),radius=0.1)

for(i in 1:30) {
  col = hsv(runif(1))
  scene = add_shape(scene, sphere_mesh(position=runif(3),
                                       material=material_list(diffuse=col, type="toon",toon_levels = 3,
                                                              toon_outline_width = 0.025,
                                                              ambient=col, ambient_intensity=0.2),
                                       radius=0.1))
}

rasterize_scene(scene, light_info=directional_light(direction=c(0.5,0.8,1)),
                background = "white",fov=10)
#> Setting `lookat` to: c(0.53, 0.49, 0.50)

You can also include a environment map to use for reflective, semi-reflective, and refractive surfaces. The roughness of the reflection can be controlled on a per-material basis with the reflection_sharpness argument.

tempfilehdr = tempfile(fileext = ".hdr")
download.file("https://www.tylermw.com/data/venice_sunset_2k.hdr",tempfilehdr)

scene = torus_mesh(position=c(0.4,0,0),angle=c(-30,20,-30),
                   material=material_list(diffuse=c(1,1,1), type="color", 
                                           reflection_intensity = 1.0, reflection_sharpness = 0.2),
                   ring_radius=0.05,radius=0.2) |>
  add_shape(torus_mesh(position=c(0.4,0.5,0),angle=c(-30,20,-130),
                   material=material_list(diffuse="green", ambient="green", type="phong", 
                                          ambient_intensity = 0.2, diffuse_intensity=0.8,
                                          reflection_intensity = 0.5, reflection_sharpness = 0.05),
                   ring_radius=0.05,radius=0.2)) |>
  add_shape(sphere_mesh(position=c(-0.4,0,0),
                   material=material_list(diffuse="white", type="color",ior=1.6),radius=0.2)) |>
  add_shape(obj_mesh(r_obj(),position=c(-0.4,0.35,0),scale=0.2, angle=c(0,-30,0),
                   material=material_list(diffuse="purple", type="color",ior=1.6))) |>
  add_shape(sphere_mesh(position=c(0,0.25,0),
                   material=material_list(diffuse="white", type="color",reflection_intensity = 1.0),
                   radius=0.2)) 

rasterize_scene(scene, lookat=c(0,0.25,0),
                light_info=directional_light(direction=c(0.5,1,1)),
                lookfrom=c(0,0.5,2.5), 
                fov=30, environment_map = tempfilehdr)

You can also blur the background but keep the reflections sharp by setting the background_sharpness argument to draw focus to your 3D scene.

rasterize_scene(scene, lookat=c(0,0.25,0),
                light_info=directional_light(direction=c(0.5,1,1)),
                lookfrom=c(0,0.5,2.5), 
                fov=30, environment_map = tempfilehdr, background_sharpness = 0.5)

Now let’s draw another example scene: we’ll add the R OBJ to a flat surface.

base_model = cube_mesh() |>
  scale_mesh(scale=c(5,0.2,5)) |>
  translate_mesh(c(0,-0.1,0)) |>
  set_material(diffuse="white")

r_model = obj_mesh(r_obj()) |>
  scale_mesh(scale=0.5) |>
  set_material(diffuse="red") |>
  add_shape(base_model)

rasterize_scene(r_model, lookfrom=c(2,4,10),fov=20,
               light_info = directional_light(direction=c(0.8,1,0.7)))
#> Setting `lookat` to: c(0.00, 0.34, 0.00)

We can reduce the shadow intensity so the shadows aren’t black. Alternatively, you can add an ambient term to the material.

#Zoom in and reduce the shadow mapping intensity
rasterize_scene(r_model, lookfrom=c(2,4,10), fov=10,shadow_map = TRUE, shadow_map_intensity=0.3,
               light_info = directional_light(direction=c(0.8,1,0.7)))
#> Setting `lookat` to: c(0.00, 0.34, 0.00)

We can increase the resolution of the shadow map to increase the fidelity of the shadows. This can reduce the amount of “pixelation” around the edges.

rasterize_scene(r_model, lookfrom=c(2,4,10), fov=10,
                shadow_map_dims=2, light_info = directional_light(direction=c(0.8,1,0.7)))
#> Setting `lookat` to: c(0.00, 0.34, 0.00)

We can add multiple directional lights and change their color and intensity:

lights = directional_light(c(0.7,1.1,-0.9),color = "orange",intensity = 0.7) |>
            add_light(directional_light(c(0.7,1,1),color = "dodgerblue",intensity = 0.7)) |>
            add_light(directional_light(c(2,4,10),color = "white",intensity = 0.3))
rasterize_scene(r_model, lookfrom=c(2,4,10), fov=10,
               light_info = lights)
#> Setting `lookat` to: c(0.00, 0.34, 0.00)

We can change the transparency of the material, which allows for colored shadows.

r_model_t = obj_mesh(r_obj()) |>
  scale_mesh(scale=0.5) |>
  set_material(diffuse="red", dissolve=0.5, translucent = T) |>
  add_shape(base_model)

r_model_t = obj_mesh(r_obj(),position = c(-2,0,0.3)) |>
  scale_mesh(scale=0.5) |>
  set_material(diffuse="dodgerblue", dissolve=0.5, translucent = T) |>
  add_shape(r_model_t)

rasterize_scene(r_model_t, lookfrom=c(2,4,10),fov=15,lookat=c(-0.5,0,0),
                light_info = directional_light(direction=c(0.8,1,0.7), intensity = 0.5) |>
                   add_light(directional_light(direction=c(-0.8,1,0.7),intensity = 0.5)))

We can also add some point lights:

#Add some point lights
lights_p = lights |>
  add_light(point_light(position=c(-1,1,0),color="red", intensity=2)) |>
  add_light(point_light(position=c(1,1,0),color="purple", intensity=2))

rasterize_scene(r_model, lookfrom=c(2,4,10), fov=10,
               light_info = lights_p)
#> Setting `lookat` to: c(0.00, 0.34, 0.00)

We can change the camera position by adjusting the lookfrom argument:

#change the camera position
rasterize_scene(r_model, lookfrom=c(-2,2,-10), fov=10,
               light_info = lights_p)
#> Setting `lookat` to: c(0.00, 0.34, 0.00)

Finally, we can also add 3D lines to the scene. We’ll add a spiral of lines around the R.

t = seq(0,8*pi,length.out=361)
line_mat = matrix(nrow=0,ncol=9)

for(i in 1:360) {
  line_mat = add_lines(line_mat,
                      generate_line(start = c(0.5*sin(t[i]), t[i]/(8*pi), 0.5*cos(t[i])),
                                    end  = c(0.5*sin(t[i+1]), t[i+1]/(8*pi), 0.5*cos(t[i+1]))))
}

rasterize_scene(r_model, lookfrom=c(2,4,10), fov=10, line_info = line_mat,
               light_info = lights)
#> Setting `lookat` to: c(0.00, 0.34, 0.00)

rayvertex's People

Contributors

jeroen avatar trevorld avatar tylermorganwall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rayvertex's Issues

Could you please do a CRAN (bug fix) release?

  • Thanks for the awesome rayvertex package!
  • Could you please do a CRAN (bug fix) release?
  • In particular your initial CRAN v0.2.3 release has a Wavefront OBJ import bug that is blocking me from merging in a PR supporting {rayvertex} in my package (and eventually releasing to CRAN) since such a feature isn't CRAN-ready (since it doesn't work with the CRAN release of your package). However you fixed that bug in the development version back in June (v0.2.4?).

`obj_mesh()` meshes don't pass `validate_mesh()`?

I'm observing in v0.7.9 that certain meshes generated by obj_mesh() no longer seem to have shadows when rendered by rasterize_scene() (unlike in earlier versions of {rayvertex}) but my attempted reproducible example won't even run in v0.8.0 since it seems my meshes generated by obj_mesh() don't seem to pass validate_mesh():

# generate Wavefront OBJ file with {piecepackr}
library("piecepackr")
envir <- game_systems()
f <- save_piece_obj(piece_side = "bit_face", x = 3, y = 1, suit = 4, cfg = envir$go)

# import/render Wavefront OBJ file in {rayvertex}
library("rayvertex")
stone <- obj_mesh(f$obj)
table <- sphere_mesh(c(0, 0, -1e3), radius=1e3,
                     material = material_list(diffuse="grey40"))
scene <- add_shape(table, stone)
light_info <- directional_light(c(5, -7, 7), intensity = 2.5)
rayvertex::rasterize_scene(scene,
                           lookat = c(4.5, 4, 0),
                           lookfrom=c(4.5, -16, 20),
                           light_info = light_info)
Error in validate_mesh(scene) : 
  is.numeric(material$toon_outline_color) is not TRUE
validate_mesh(stone)
Error in validate_mesh(stone) : 
  is.numeric(material$toon_outline_color) is not TRUE

Regression in rendering textured meshes (imported via Wavefront OBJ files)

In {rayvertex} v0.4.11 I'm observing a regression in rendering a textured mesh imported via Wavefront OBJ file:

# generate Wavefront OBJ file with {piecepackr}
library("piecepackr")
envir <- game_systems("sans3d", round=TRUE)
f <- save_piece_obj(piece_side = "tile_back", x = 1.5, y = 1.5, suit = 1, rank = 1,
                    cfg = envir$piecepack)

# import/render Wavefront OBJ file in {rayvertex}
library("rayvertex")
tile <- obj_mesh(f$obj)
table <- sphere_mesh(c(0, 0, -1e3), radius=1e3, material = material_list(diffuse="grey40"))
scene <- add_shape(table, tile)
rasterize_scene(scene, filename = "rayvertex_bug.png",
                lookat = c(4.5, 4, 0), lookfrom=c(4.5, -16, 20),
                light_info = directional_light(c(5, -7, 7), intensity = 2.5))

rayvertex_bug

In contrast things look fine with the latest version of {rayrender} (also look fine with {rgl} via {readobj} or an earlier version of {rayvertex} like v0.3.3)

# contrast with {rayrender}
library("rayrender")
tile <- obj_model(f$obj, load_textures = TRUE, load_material = TRUE)
table <- sphere(z=-1e3, radius=1e3, material=diffuse(color="grey40")) |>
         add_object(sphere(x=5,y=-4, z=30, material=light(intensity=420)))
scene <- add_object(table, tile)
render_scene(scene, filename = "rayrender.png",
             lookat = c(5, 5, 0), lookfrom = c(5, -7, 25),
             width = 500, height = 500, samples=200, clamp_value=8)

rayrender

feature request: Also allow number of cores to be set by `getOption("Ncpus")`

Currently rasterize_scene() and rasterize_lines() has:

  if(!is.null(options("cores")[[1]])) {
    numbercores = options("cores")[[1]]
  } else {
    numbercores = parallel::detectCores()
  }
  if(!parallel) {
    numbercores = 1
  }

Perhaps we should update that to match the new logic in {rayrender}:

  numbercores = getOption("cores", default = getOption("Ncpus", default = parallel::detectCores()))
  if(!parallel) {
    numbercores = 1
  }

for similar reasons as in tylermorganwall/rayrender#46

If this change is okay I could put together a PR

toon_outline_width of 0 should result in no outline

When using the material_list function with type = "toon", I think having toon_outline_width = 0 should result in no outline. Instead, it makes all the objects red. I didn't see another option to remove the outline, but I might have missed it.

remotes::install_github("tylermorganwall/rayvertex")
#> Skipping install of 'rayvertex' from a github remote, the SHA1 (f1c3289f) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(rayvertex)

# Example works like the documentation
set.seed(1)
col = hsv(runif(1))
scene = sphere_mesh(position=runif(3),
                    material=material_list(diffuse=col, type="toon",toon_levels = 3, 
                                           toon_outline_width = 0.025,
                                           ambient=col,ambient_intensity=0.2),radius=0.1)

for(i in 1:30) {
  col = hsv(runif(1))
  scene = add_shape(scene, sphere_mesh(position=runif(3),
                                       material=material_list(diffuse=col, type="toon",toon_levels = 3,
                                                              toon_outline_width = 0.025,
                                                              ambient=col, ambient_intensity=0.2),
                                       radius=0.1))
}

rasterize_scene(scene,
                light_info=directional_light(direction=c(0.5,0.8,1)),
                background = "white",fov=10)
#> Setting `lookat` to: c(0.53, 0.49, 0.50)

# set toon_outline_width = 0
# I'd expect this to be the previous image with no black outlines on the spheres
# but it makes all of them red instead?
set.seed(1)
col = hsv(runif(1))
scene = sphere_mesh(position=runif(3),
                    material=material_list(diffuse=col, type="toon",toon_levels = 3, 
                                           toon_outline_width = 0,
                                           ambient=col,ambient_intensity=0.2),radius=0.1)

for(i in 1:30) {
  col = hsv(runif(1))
  scene = add_shape(scene, sphere_mesh(position=runif(3),
                                       material=material_list(diffuse=col, type="toon",toon_levels = 3,
                                                              toon_outline_width = 0,
                                                              ambient=col, ambient_intensity=0.2),
                                       radius=0.1))
}

rasterize_scene(scene,
                light_info=directional_light(direction=c(0.5,0.8,1)),
                background = "white",fov=10)
#> Setting `lookat` to: c(0.53, 0.49, 0.50)

# set toon_outline_width = -0.025
# This gets the desired result, but feels hacky
set.seed(1)
col = hsv(runif(1))
scene = sphere_mesh(position=runif(3),
                    material=material_list(diffuse=col, type="toon",toon_levels = 3, 
                                           toon_outline_width = -0.025,
                                           ambient=col,ambient_intensity=0.2),radius=0.1)

for(i in 1:30) {
  col = hsv(runif(1))
  scene = add_shape(scene, sphere_mesh(position=runif(3),
                                       material=material_list(diffuse=col, type="toon",toon_levels = 3,
                                                              toon_outline_width = -0.025,
                                                              ambient=col, ambient_intensity=0.2),
                                       radius=0.1))
}

rasterize_scene(scene,
                light_info=directional_light(direction=c(0.5,0.8,1)),
                background = "white",fov=10)
#> Setting `lookat` to: c(0.53, 0.49, 0.50)

Sys.info()
#>                                                                                                 sysname 
#>                                                                                                "Darwin" 
#>                                                                                                 release 
#>                                                                                                "21.5.0" 
#>                                                                                                 version 
#> "Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101" 
#>                                                                                                nodename 
#>                                                                                            "Tylers-MBP" 
#>                                                                                                 machine 
#>                                                                                                "x86_64" 
#>                                                                                                   login 
#>                                                                                                  "root" 
#>                                                                                                    user 
#>                                                                                          "tylerbradley" 
#>                                                                                          effective_user 
#>                                                                                          "tylerbradley"

Created on 2022-06-08 by the reprex package (v2.0.1)

'scene_from_list()' bug

I've found a case with {rayvertex} v0.4.11 where scene_from_list() throws an ERROR when building a scene from a list of "ray_mesh" objects:

library("piecepackr")
library("ppgames") # remotes::install_github("piecepackr/ppgames")
library("rayvertex", warn.conflicts = FALSE) # masks `rayrender::r_obj`
df <- ppgames::df_international_chess()
envir <- game_systems("dejavu3d", round=TRUE, pawn="joystick")
l <- pmap_piece(df, piece_mesh, trans=op_transform, envir = envir, scale = 0.98, res = 150, as_top="pawn_face")
scene <- scene_from_list(l)
Error in scene_list[[i]]$material_hashes[[j]] : subscript out of bounds

Note though one can still build a scene from this list of "ray_mesh" objects by using add_shape() perhaps via Reduce():

scene <- Reduce(add_shape, l)

Note every element of the list is a "ray_mesh"

> vapply(l, function(x) inherits(x, "ray_mesh"), logical(1))
piece.16 piece.15 piece.14 piece.13 piece.12 piece.11 piece.10  piece.9 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 
 piece.8  piece.7  piece.6  piece.5  piece.4  piece.3  piece.2  piece.1 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 
piece.38 piece.47 piece.45 piece.37 piece.24 piece.23 piece.22 piece.21 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 
piece.20 piece.19 piece.18 piece.17 piece.32 piece.31 piece.30 piece.29 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 
piece.28 piece.27 piece.26 piece.25 piece.39 piece.48 piece.46 piece.40 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 
piece.34 piece.33 piece.35 piece.36 piece.42 piece.41 piece.43 piece.44 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 

Linux install fails

Hi there, I am unable to install the package in Linux (R3.6):

install.packages("rayvertex")
Installing package into ‘/home/apascual/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
probando la URL 'http://stat.ethz.ch/CRAN/src/contrib/rayvertex_0.4.11.tar.gz'
Content type 'application/x-gzip' length 468801 bytes (457 KB)
==================================================
downloaded 457 KB

*** Successfully loaded .Rprofile ***

  • installing source package ‘rayvertex’ ...
    ** package ‘rayvertex’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c filltri.cpp -o filltri.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c light.cpp -o light.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c line.cpp -o line.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c load_obj.cpp -o load_obj.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c load_ply.cpp -o load_ply.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c miniply.cpp -o miniply.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c rasterize_lines_rcpp.cpp -o rasterize_lines_rcpp.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c rayimage.cpp -o rayimage.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c rayraster.cpp -o rayraster.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c shaders.cpp -o shaders.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c tonemap.cpp -o tonemap.o
    g++ -std=gnu++17 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/spacefillr/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/RcppThread/include" -I"/home/apascual/R/x86_64-pc-linux-gnu-library/3.6/rayimage/include" -I/usr/local/include -I../src/glm -I../src/glm/gtc -fpic -g -O2 -c wireframe.cpp -o wireframe.o
    g++ -std=gnu++17 -shared -L/opt/R/3.6.3/lib/R/lib -L/usr/local/lib -o rayvertex.so RcppExports.o filltri.o light.o line.o load_obj.o load_ply.o miniply.o rasterize_lines_rcpp.o rayimage.o rayraster.o shaders.o tonemap.o wireframe.o -L/opt/R/3.6.3/lib/R/lib -lR
    installing to /home/apascual/R/x86_64-pc-linux-gnu-library/3.6/00LOCK-rayvertex/00new/rayvertex/libs
    ** R
    Error in parse(outFile) :
    /tmp/Rtmpb2IhYf/R.INSTALL18d55fa23fa0/rayvertex/R/add_shape.R:795:30: unexpected '>'
    794: scaleval = (bbox_size + material$toon_outline_width)/bbox_size
    795: single_obj = single_obj |>
    ^
    ERROR: unable to collate and parse R files for package ‘rayvertex’

I've seen a similar problem here that seems to be related with an encoding problem.

Thanks in advance

Dark spots in raster

Hi!

Thanks for the great package.

I am trying to replicate my brain rendering workflow, porting from rayrender to rayvertex, and something weird happened: some dark spots appear in some parts of the image.

See video:

brain_raster_rot.mp4

The code I use for this is pretty simple, as every shape is loaded as a mesh3d_mesh in the scene and the scene frames are rendered in parallel (takes 2 minutes to render 90 frames)

vb.center = c(254, 160, -220)
dist.from = 1350

steps = 180
steps.x = dist.from * 2 * cos(seq(0, 360, length.out = steps) * pi/180)
steps.z = dist.from * 2 * sin(seq(0, 360, length.out = steps) * pi/180)
 
scene = mesh3d_mesh(meshlist[[1]])

for(i in names(meshlist)) {
    mesh.material = paste0("#", structures.available$color_hex_triplet[structures.available$id == i])
    scene <- add_shape(scene, 
                       shape = mesh3d_mesh(meshlist[[i]], 
                       material = material_list(diffuse = mesh.material)))
    }

plan(multiprocess, workers = 13) 

future.apply::future_lapply(1:90, function(j) {
  options(cores = 4)
  rasterize_scene(scene = scene,
               lookat = vb.center,
               lookfrom = c(steps.x[j*2], 50, steps.z[j*2]),
               width = 1080,
               height = 1080,
               light_info = directional_light(c(steps.x[j*2], 50, steps.z[j*2]), 
                                                                color = "white", 
                                                                intensity = 0.8),
               background = "white",
               parallel = TRUE, 
               filename=glue::glue("./raster/brainmov_rast_{j}"))
            },
    future.seed = TRUE)

A similar workflow in rayrender has no such issue.

Any idea if I'm doing something wrong/need to change arguments?

Mac install fails

Installation using install_github on Mac (Big Sur 11.5.2) fails with this error:

clang++ -I"/usr/local/Cellar/r/4.0.4/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.0/site-library/Rcpp/include' -I'/usr/local/lib/R/4.0/site-library/spacefillr/include' -I'/usr/local/lib/R/4.0/site-library/RcppThread/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include  -I../src/glm -I../src/glm/gtc -fPIC  -g -O2  -c filltri.cpp -o filltri.o
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread.h:9:
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/RMonitor.hpp:44:33: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    RMonitor(RMonitor const&) = delete;
                                ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/RMonitor.hpp:46:22: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    RMonitor(RMonitor&&) = delete;
                     ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/RMonitor.hpp:46:28: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    RMonitor(RMonitor&&) = delete;
                           ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/RMonitor.hpp:48:44: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    RMonitor& operator=(RMonitor const&) = delete;
                                           ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/RMonitor.hpp:50:34: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    RMonitor& operator=(RMonitor &&) = delete;
                                 ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/RMonitor.hpp:50:40: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    RMonitor& operator=(RMonitor &&) = delete;
                                       ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread.h:11:
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:29:16: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
    Thread() = default;
               ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:30:23: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    Thread(Thread&) = delete;
                      ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:31:29: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    Thread(const Thread&) = delete;
                            ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:32:18: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    Thread(Thread&& other)
                 ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:37:35: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
    template<class Function, class... Args> explicit
                                  ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:38:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    Thread(Function&& f, Args&&... args)
                   ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:38:30: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    Thread(Function&& f, Args&&... args)
                             ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:49:14: error: expected ';' at end of declaration list
    ~Thread() noexcept
             ^
             ;
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:58:29: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    Thread& operator=(Thread&& other)
                            ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:66:29: error: expected ';' at end of declaration list
    void swap(Thread& other) noexcept
                            ^
                            ;
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:40:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
        auto f0 = [=] () {
        ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:40:19: error: expected expression
        auto f0 = [=] () {
                  ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:44:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
        auto task = std::packaged_task<void()>(f0);
        ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:46:9: error: use of undeclared identifier 'thread_'
        thread_ = std::thread(std::move(task));
        ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Thread.hpp:60:13: error: use of undeclared identifier 'thread_'
        if (thread_.joinable())
            ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread.h:12:
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Batch.hpp:33:22: error: expected '(' for function-style cast or type construction
        return {Batch{0, 0}};
                ~~~~~^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/Batch.hpp:45:27: error: expected '(' for function-style cast or type construction
        batches[k] = Batch{bBegin, bBegin + bSize};
                     ~~~~~^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread.h:13:
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:29:26: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    ThreadPool(ThreadPool&&) = delete;
                         ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:29:32: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ThreadPool(ThreadPool&&) = delete;
                               ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:30:37: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ThreadPool(const ThreadPool&) = delete;
                                    ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:34:18: error: expected ';' at end of declaration list
    ~ThreadPool() noexcept;
                 ^
                 ;
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:36:48: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ThreadPool& operator=(const ThreadPool&) = delete;
                                               ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:37:37: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    ThreadPool& operator=(ThreadPool&& other) = delete;
                                    ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:37:49: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ThreadPool& operator=(ThreadPool&& other) = delete;
                                                ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:39:28: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
    template<class F, class... Args>
                           ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:40:16: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void push(F&& f, Args&&... args);
               ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:40:26: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void push(F&& f, Args&&... args);
                         ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:42:28: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
    template<class F, class... Args>
                           ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:43:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
    auto pushReturn(F&& f, Args&&... args)
    ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:43:22: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    auto pushReturn(F&& f, Args&&... args)
                     ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:43:32: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    auto pushReturn(F&& f, Args&&... args)
                               ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:43:5: error: 'auto' not allowed in function return type
    auto pushReturn(F&& f, Args&&... args)
    ^~~~
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:43:43: error: expected ';' at end of declaration list
    auto pushReturn(F&& f, Args&&... args)
                                          ^
                                          ;
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:47:15: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void map(F&& f, I &&items);
              ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:47:23: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void map(F&& f, I &&items);
                      ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:52:30: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
                            F&& f,
                             ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:56:44: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    inline void parallelForEach(I& items, F&& f, size_t nBatches = 0);
                                           ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:64:37: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void doJob(std::function<void()>&& job);
                                    ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:64:21: warning: 'function<void ()>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
    void doJob(std::function<void()>&& job);
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:27: note: 'function<void ()>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1439:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread.h:13:
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:76:36: warning: use of right-shift operator ('>>') in template argument will require parentheses in C++11 [-Wc++11-compat]
    std::queue<std::function<void()>> jobs_;  // the task que
                                   ^
                             (             )
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:76:39: error: use of undeclared identifier 'jobs_'
    std::queue<std::function<void()>> jobs_;  // the task que
                                      ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:76:44: error: expected '>'
    std::queue<std::function<void()>> jobs_;  // the task que
                                           ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:76:29: note: to match this '<'
    std::queue<std::function<void()>> jobs_;  // the task que
                            ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:76:44: error: expected a type
    std::queue<std::function<void()>> jobs_;  // the task que
                                           ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:76:44: error: expected '>'
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:76:15: note: to match this '<'
    std::queue<std::function<void()>> jobs_;  // the task que
              ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:82:12: error: function definition does not declare parameters
    size_t numBusy_{0};
           ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:83:10: error: function definition does not declare parameters
    bool stopped_{false};
         ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:89:5: error: delegating constructors are permitted only in C++11
    ThreadPool(std::thread::hardware_concurrency())
    ^~~~~~~~~~
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/ThreadPool.hpp:103:34: error: expected function body after function declarator
inline ThreadPool::~ThreadPool() noexcept
                                 ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread.h:14:
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/parallelFor.hpp:43:59: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
inline void parallelFor(ptrdiff_t begin, ptrdiff_t size, F&& f,
                                                          ^
/usr/local/lib/R/4.0/site-library/RcppThread/include/RcppThread/parallelFor.hpp:81:40: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
inline void parallelForEach(I& items, F&& f,
                                       ^
38 warnings and 18 errors generated.
make: *** [filltri.o] Error 1
ERROR: compilation failed for package ‘rayvertex’

Missing license for GLM

GLM is used but no copy of its license appears to be redistributed. Note that this is a requirement of the license:

"The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."

Please include a copy of the license.

Bump {rayimage} version requirement in DESCRIPTION?

  1. I tried updating my version of {rayvertex} to 0.3.3 and I initially got the following error:
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/spacefillr/include' -I'/usr/local/lib/R/site-library/RcppThread/include' -I'/usr/local/lib/R/site-library/rayimage/include'   -I../src/glm -I../src/glm/gtc -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-QwogzP/r-base-4.1.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c rayraster.cpp -o rayraster.o
rayraster.cpp:20:10: fatal error: stb_image_resize.h: No such file or directory
   20 | #include "stb_image_resize.h"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
  1. I then installed the system package libstb-dev then tried updating {rayvertex} again and still observed the same error.
  2. I then updated {rayimage} and then tried updating {rayvertex} again and it worked.

So maybe the newer version of {rayvertex} requires a newer version of {rayimage}?

add_shape(NULL, NULL) now throws ERROR

Unlike earlier versions of {rayvertex} where add_shape(NULL, NULL) returned a NULL I now observe that it throws an ERROR:

library("rayvertex")
scene <- add_shape(NULL, NULL)
Error in class(scene) <- c("ray_mesh", "list") : 
  attempt to set an attribute on NULL

In contrast scene_from_list() does seem to handle this case:

scene_from_list(list(NULL, NULL))
$shapes
list()

$materials
list()

$vertices
$vertices[[1]]
NULL


$texcoords
$texcoords[[1]]
NULL


$normals
$normals[[1]]
NULL


$material_hashes
character(0)

attr(,"class")
[1] "ray_mesh" "list"    

Is there something else I should be using for a "null" mesh other than NULL
(i.e. a mesh too small or transparent that we know won't be visible and shouldn't be drawn as sometimes happens in animation transitions when things are appearing or disappearing)?

Regression in importing textured meshes from Wavefront OBJ files

I received an e-mail from Prof. Ripley today informing me that the newest release of {rayvertex} is triggering a CRAN check ERROR in {piecepackr} when running the \donttest{} examples. A simplified version of the \donttest{} example which worked in earlier versions of {rayvertex}:

library("piecepackr")
envir <- game_systems("sans3d", round=TRUE)
f <- save_piece_obj(piece_side = "tile_back", x = 1.5, y = 1.5, suit = 1, rank = 1,
                    cfg = envir$piecepack)

# import/render Wavefront OBJ file in {rayvertex}
library("rayvertex")
tile <- obj_mesh(f$obj)
table <- sphere_mesh(c(0, 0, -1e3), radius=1e3, material = material_list(diffuse="grey40"))
scene <- add_shape(table, tile)
rasterize_scene(scene, filename = "rayvertex_bug.png",
                lookat = c(4.5, 4, 0), lookfrom=c(4.5, -16, 20),
                light_info = directional_light(c(5, -7, 7), intensity = 2.5))
Error: Number of items is not equal to specified material length.

Enter a frame number, or 0 to exit   

1: obj_mesh(f$obj)
2: objects.R#732: read_obj(filename, materialspath)
3: readobj.R#29: load_obj(filename, dir)

This is a different bug from #9

Installation failing (R4.1.0, macOS Big Sur 11.4)

Installation via devtools failing on my macOS11.4

Installation output attached below.

R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.4
> devtools::install_github("tylermorganwall/rayvertex")
Downloading GitHub repo tylermorganwall/rayvertex@HEAD
✓  checking for file ‘/private/var/folders/5p/78cv9fvn4xn_rbgxpx51q5n80000gn/T/RtmpxF6cQM/remotes38e74e11f542/tylermorganwall-rayvertex-6bcb46a/DESCRIPTION’ ...
─  preparing ‘rayvertex’: (341ms)
✓  checking DESCRIPTION meta-information
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘rayvertex_0.1.tar.gz’
   
* installing *source* package ‘rayvertex’ ...
** using staged installation
** libs
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/spacefillr/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include' -I/usr/local/include  -I../src/glm -I../src/glm/gtc -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:57:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable 'data' [-Wunused-variable]
            SEXP data = Parent::get__();
                 ^
1 warning generated.
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/spacefillr/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include' -I/usr/local/include  -I../src/glm -I../src/glm/gtc -fPIC  -Wall -g -O2  -c filltri.cpp -o filltri.o
In file included from filltri.cpp:1:
In file included from ./filltri.h:5:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:57:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable 'data' [-Wunused-variable]
            SEXP data = Parent::get__();
                 ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread.h:9:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/RMonitor.hpp:44:33: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    RMonitor(RMonitor const&) = delete;
                                ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/RMonitor.hpp:46:22: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    RMonitor(RMonitor&&) = delete;
                     ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/RMonitor.hpp:46:28: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    RMonitor(RMonitor&&) = delete;
                           ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/RMonitor.hpp:48:44: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    RMonitor& operator=(RMonitor const&) = delete;
                                           ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/RMonitor.hpp:50:34: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    RMonitor& operator=(RMonitor &&) = delete;
                                 ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/RMonitor.hpp:50:40: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    RMonitor& operator=(RMonitor &&) = delete;
                                       ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread.h:11:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:29:16: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
    Thread() = default;
               ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:30:23: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    Thread(Thread&) = delete;
                      ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:31:29: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    Thread(const Thread&) = delete;
                            ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:32:18: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    Thread(Thread&& other)
                 ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:37:35: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
    template<class Function, class... Args> explicit
                                  ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:38:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    Thread(Function&& f, Args&&... args)
                   ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:38:30: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    Thread(Function&& f, Args&&... args)
                             ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:49:14: error: expected ';' at end of declaration list
    ~Thread() noexcept
             ^
             ;
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:58:29: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    Thread& operator=(Thread&& other)
                            ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:66:29: error: expected ';' at end of declaration list
    void swap(Thread& other) noexcept
                            ^
                            ;
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:40:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
        auto f0 = [=] () {
        ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:40:19: error: expected expression
        auto f0 = [=] () {
                  ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:44:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
        auto task = std::packaged_task<void()>(f0);
        ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:46:9: error: use of undeclared identifier 'thread_'
        thread_ = std::thread(std::move(task));
        ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Thread.hpp:60:13: error: use of undeclared identifier 'thread_'
        if (thread_.joinable())
            ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread.h:12:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Batch.hpp:33:22: error: expected '(' for function-style cast or type construction
        return {Batch{0, 0}};
                ~~~~~^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/Batch.hpp:45:27: error: expected '(' for function-style cast or type construction
        batches[k] = Batch{bBegin, bBegin + bSize};
                     ~~~~~^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread.h:13:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:29:26: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    ThreadPool(ThreadPool&&) = delete;
                         ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:29:32: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ThreadPool(ThreadPool&&) = delete;
                               ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:30:37: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ThreadPool(const ThreadPool&) = delete;
                                    ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:34:18: error: expected ';' at end of declaration list
    ~ThreadPool() noexcept;
                 ^
                 ;
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:36:48: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ThreadPool& operator=(const ThreadPool&) = delete;
                                               ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:37:37: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    ThreadPool& operator=(ThreadPool&& other) = delete;
                                    ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:37:49: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ThreadPool& operator=(ThreadPool&& other) = delete;
                                                ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:39:28: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
    template<class F, class... Args>
                           ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:40:16: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void push(F&& f, Args&&... args);
               ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:40:26: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void push(F&& f, Args&&... args);
                         ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:42:28: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
    template<class F, class... Args>
                           ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:43:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
    auto pushReturn(F&& f, Args&&... args)
    ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:43:22: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    auto pushReturn(F&& f, Args&&... args)
                     ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:43:32: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    auto pushReturn(F&& f, Args&&... args)
                               ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:43:5: error: 'auto' not allowed in function return type
    auto pushReturn(F&& f, Args&&... args)
    ^~~~
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:43:43: error: expected ';' at end of declaration list
    auto pushReturn(F&& f, Args&&... args)
                                          ^
                                          ;
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:47:15: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void map(F&& f, I &&items);
              ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:47:23: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void map(F&& f, I &&items);
                      ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:52:30: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
                            F&& f,
                             ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:56:44: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    inline void parallelForEach(I& items, F&& f, size_t nBatches = 0);
                                           ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:64:37: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
    void doJob(std::function<void()>&& job);
                                    ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:64:21: warning: 'function<void ()>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
    void doJob(std::function<void()>&& job);
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:27: note: 'function<void ()>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1439:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread.h:13:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:76:36: warning: use of right-shift operator ('>>') in template argument will require parentheses in C++11 [-Wc++11-compat]
    std::queue<std::function<void()>> jobs_;  // the task que
                                   ^
                             (             )
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:76:39: error: use of undeclared identifier 'jobs_'
    std::queue<std::function<void()>> jobs_;  // the task que
                                      ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:76:44: error: expected '>'
    std::queue<std::function<void()>> jobs_;  // the task que
                                           ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:76:29: note: to match this '<'
    std::queue<std::function<void()>> jobs_;  // the task que
                            ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:76:44: error: expected a type
    std::queue<std::function<void()>> jobs_;  // the task que
                                           ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:76:44: error: expected '>'
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:76:15: note: to match this '<'
    std::queue<std::function<void()>> jobs_;  // the task que
              ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:82:12: error: function definition does not declare parameters
    size_t numBusy_{0};
           ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:83:10: error: function definition does not declare parameters
    bool stopped_{false};
         ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:89:5: error: delegating constructors are permitted only in C++11
    ThreadPool(std::thread::hardware_concurrency())
    ^~~~~~~~~~
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/ThreadPool.hpp:103:34: error: expected function body after function declarator
inline ThreadPool::~ThreadPool() noexcept
                                 ^
In file included from filltri.cpp:1:
In file included from ./filltri.h:7:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread.h:14:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/parallelFor.hpp:43:59: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
inline void parallelFor(ptrdiff_t begin, ptrdiff_t size, F&& f,
                                                          ^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppThread/include/RcppThread/parallelFor.hpp:81:40: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
inline void parallelForEach(I& items, F&& f,
                                       ^
filltri.cpp:36:7: warning: unused variable 'nx' [-Wunused-variable]
  int nx = image.width();
      ^
40 warnings and 18 errors generated.
make: *** [filltri.o] Error 1
ERROR: compilation failed for package ‘rayvertex’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rayvertex’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/5p/78cv9fvn4xn_rbgxpx51q5n80000gn/T//RtmpxF6cQM/file38e77cfce818/rayvertex_0.1.tar.gz’ had non-zero exit status

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.