include/container.h
author Radek Brich <radek.brich@devl.cz>
Mon, 19 May 2008 22:59:04 +0200
branchpyrit
changeset 98 64638385798a
parent 95 ca7d4c665531
permissions -rw-r--r--
add sections about demos to README update doxygen comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     1
/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     2
 * @file  container.h
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     3
 * @brief Spatial container for shapes
44
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
     4
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
     5
 * This file is part of Pyrit Ray Tracer.
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
     6
 *
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 84
diff changeset
     7
 * Copyright 2007, 2008  Radek Brich
34
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
     8
 *
44
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
     9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    10
 * of this software and associated documentation files (the "Software"), to deal
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    11
 * in the Software without restriction, including without limitation the rights
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    13
 * copies of the Software, and to permit persons to whom the Software is
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    14
 * furnished to do so, subject to the following conditions:
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    15
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    16
 * The above copyright notice and this permission notice shall be included in
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    17
 * all copies or substantial portions of the Software.
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    18
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    24
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    25
 * THE SOFTWARE.
34
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
    26
 */
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
    27
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
#ifndef CONTAINER_H
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
#define CONTAINER_H
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
#include <vector>
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
78
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 46
diff changeset
    33
#include "shapes.h"
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    35
using namespace std;
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
46
6493fb65f0b1 Doxygen
Radek Brich <radek.brich@devl.cz>
parents: 44
diff changeset
    37
/**
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    38
 * General container for shapes.
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    39
 *
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    40
 * Does very simple intersection test:
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    41
 * all shapes are tested and the nearest intersection is returned.
46
6493fb65f0b1 Doxygen
Radek Brich <radek.brich@devl.cz>
parents: 44
diff changeset
    42
 */
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    43
class Container
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    44
{
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    45
protected:
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    46
	BBox bbox;
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    47
public:
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    48
	ShapeList shapes;
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    49
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    50
	Container(): bbox(), shapes() {};
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    51
	virtual ~Container() {};
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    52
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    53
	/** add pointer to shape to the container */
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    54
	virtual void addShape(const Shape* aShape);
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    55
	//void addShapeNoExtend(const Shape* aShape) { shapes.push_back(aShape); };
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    56
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    57
	/**
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    58
	 * find nearest intersection with shapes in container
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    59
	 * @param[in] origin_shape  this shape should be avoided from the test
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    60
	 * @param[in] ray           the ray
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    61
	 * @param[out] nearest_distance  the nearest allowd distance of intersection;
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    62
	 *                               it is updated when closer intersection is found
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    63
	 * @return intersected shape or NULL if no intersection was found
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    64
	 */
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    65
	virtual const Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    66
		Float &nearest_distance);
82
930a2d3ecaed prepare structures for packet tracing
Radek Brich <radek.brich@devl.cz>
parents: 78
diff changeset
    67
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    68
	/** intersect with whole ray packet */
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    69
#ifndef NO_SIMD
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    70
	virtual void packet_intersection(const Shape* const* origin_shapes, const RayPacket &rays,
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    71
		Float *nearest_distances, const Shape** nearest_shapes);
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 84
diff changeset
    72
#endif
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    73
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    74
	/** build acceleration structures */
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    75
	virtual void optimize() {};
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    76
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    77
	/** get reference to the shape list */
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    78
	ShapeList & getShapes() { return shapes; };
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    79
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    80
	/** write textual representation of the acceleration structure
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    81
	 * and shapes in list to the stream */
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    82
	virtual ostream & dump(ostream &st) const;
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    83
};
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    84
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    85
#endif