コード例 #1
0
CurveTree::CurveTree(const Arguments& arguments)
  : TreeType(AlignedAllocator<void>(System::get_l1_data_cache_line_size()))
  , m_arguments(arguments)
{
    // Retrieve construction parameters.
    const MessageContext message_context(
        format("while building curve tree for assembly \"{0}\"", m_arguments.m_assembly.get_path()));
    const ParamArray& params = m_arguments.m_assembly.get_parameters().child("acceleration_structure");
    const string algorithm = params.get_optional<string>("algorithm", "bvh", make_vector("bvh", "sbvh"), message_context);
    const double time = params.get_optional<double>("time", 0.5);

    // Start stopwatch.
    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    // Build the tree.
    Statistics statistics;
    if (algorithm == "bvh")
        build_bvh(params, time, statistics);
    else throw ExceptionNotImplemented();

    // Print curve tree statistics.
    statistics.insert_size("nodes alignment", alignment(&m_nodes[0]));
    statistics.insert_time("total time", stopwatch.measure().get_seconds());
    RENDERER_LOG_DEBUG("%s",
        StatisticsVector::make(
            "curve tree #" + to_string(m_arguments.m_curve_tree_uid) + " statistics",
            statistics).to_string().c_str());
}
コード例 #2
0
int main(int argc, char** argv)
{
    bvh_obj bvh;
    unsigned int num_tris = sizeof(indices) / (sizeof(indices[0]) * 3);
    const unsigned int num_vertices =  sizeof(vertices) / (sizeof(vertices[0]) * 3);
    float* align_verts = aligned_malloc(sizeof(float) * 4 * num_vertices, 16);
    for (unsigned int i = 0; i < num_vertices; i++) {
        align_verts[i * 4 + 0] = vertices[i * 3 + 0];
        align_verts[i * 4 + 1] = vertices[i * 3 + 1];
        align_verts[i * 4 + 2] = vertices[i * 3 + 2];
        align_verts[i * 4 + 3] = 1.0f;
    }

    clock_t c = clock();
    unsigned int num_nodes = build_bvh(indices, num_tris, align_verts, &bvh);
    printf("time : %ld ms\n", (clock() - c) * 1000 / CLOCKS_PER_SEC);
    printf("nodes : %u\n", num_nodes);
    destroy_bvh(&bvh);
    aligned_free(align_verts);
}