Spaces:
Runtime error
Runtime error
File size: 3,239 Bytes
be11144 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
#pragma once
#include "diffvg.h"
#include "aabb.h"
#include <vector>
struct Shape;
struct ShapeGroup;
struct Filter;
struct DFilter;
struct BVHNode {
int child0, child1; // child1 is negative if it is a leaf
AABB box;
float max_radius;
};
struct Scene {
Scene(int canvas_width,
int canvas_height,
const std::vector<const Shape *> &shape_list,
const std::vector<const ShapeGroup *> &shape_group_list,
const Filter &filter,
bool use_gpu,
int gpu_index);
~Scene();
int canvas_width;
int canvas_height;
uint8_t *buffer;
Shape *shapes;
Shape *d_shapes;
ShapeGroup *shape_groups;
ShapeGroup *d_shape_groups;
Filter *filter;
DFilter *d_filter;
// For accelerating intersection
AABB *shapes_bbox;
BVHNode **path_bvhs; // Only for Path
BVHNode **shape_groups_bvh_nodes; // One BVH for each shape group
BVHNode *bvh_nodes;
int num_shapes;
int num_shape_groups;
// shape_groups reuse shape, so the total number of shapes
// doesn't equal to num_shapes
int num_total_shapes;
bool use_gpu;
int gpu_index;
// For edge sampling
float *shapes_length;
float *sample_shapes_cdf;
float *sample_shapes_pmf;
int *sample_shape_id;
int *sample_group_id;
float **path_length_cdf;
float **path_length_pmf;
int **path_point_id_map;
ShapeGroup get_d_shape_group(int group_id) const;
Shape get_d_shape(int shape_id) const;
float get_d_filter_radius() const;
};
struct SceneData {
int canvas_width;
int canvas_height;
Shape *shapes;
Shape *d_shapes;
ShapeGroup *shape_groups;
ShapeGroup *d_shape_groups;
Filter *filter;
DFilter *d_filter;
AABB *shapes_bbox;
BVHNode **path_bvhs; // Only for Path
BVHNode **shape_groups_bvh_nodes;
BVHNode *bvh_nodes;
int num_shapes;
int num_shape_groups;
int num_total_shapes;
// For edge sampling
float *shapes_length;
float *sample_shapes_cdf;
float *sample_shapes_pmf;
int *sample_shape_id;
int *sample_group_id;
float **path_length_cdf;
float **path_length_pmf;
int **path_point_id_map;
};
inline SceneData get_scene_data(const Scene &scene) {
return SceneData{scene.canvas_width,
scene.canvas_height,
scene.shapes,
scene.d_shapes,
scene.shape_groups,
scene.d_shape_groups,
scene.filter,
scene.d_filter,
scene.shapes_bbox,
scene.path_bvhs,
scene.shape_groups_bvh_nodes,
scene.bvh_nodes,
scene.num_shapes,
scene.num_shape_groups,
scene.num_total_shapes,
scene.shapes_length,
scene.sample_shapes_cdf,
scene.sample_shapes_pmf,
scene.sample_shape_id,
scene.sample_group_id,
scene.path_length_cdf,
scene.path_length_pmf,
scene.path_point_id_map};
}
|