include/serialize.h
author Radek Brich <radek.brich@devl.cz>
Mon, 05 May 2008 15:31:14 +0200
branchpyrit
changeset 92 9af5c039b678
parent 91 9d66d323c354
child 94 4c8abb8977dc
permissions -rw-r--r--
add MSVC compiler support, make it default for Windows new header file simd.h for SSE abstraction and helpers add mselect pseudo instruction for common or(and(...), andnot(...)) replace many SSE intrinsics with new names new MemoryPool class (mempool.h) for faster KdNode allocation remove setMaxDepth() from Octree and KdTree, make max_depth const, it should be defined in constructor and never changed, change after building tree would cause error in traversal modify DefaultSampler to generate nice 2x2 packets of samples for packet tracing optimize Box and BBox::intersect_packet add precomputed invdir attribute to RayPacket scons build system: check for pthread library on Windows check for SDL generate include/config.h with variables detected by scons configuration move auxiliary files to build/ add sanity checks add writable operator[] to Vector
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
78
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
/*
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
 * serialize.h: object serialization functions
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
 *
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
 * This file is part of Pyrit Ray Tracer.
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
 *
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
 * Copyright 2008  Radek Brich
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
 *
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
 * of this software and associated documentation files (the "Software"), to deal
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
 * in the Software without restriction, including without limitation the rights
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
 * copies of the Software, and to permit persons to whom the Software is
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
 * furnished to do so, subject to the following conditions:
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
 *
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
 * The above copyright notice and this permission notice shall be included in
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
 * all copies or substantial portions of the Software.
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
 *
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
 * THE SOFTWARE.
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
 */
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
#ifndef SERIALIZE_H
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
#define SERIALIZE_H
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
#include <map>
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
#include "shapes.h"
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    33
#include "container.h"
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
#include "kdtree.h"
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    35
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
class Indexer
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
{
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    38
	map <void *, int> indexmap;
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    39
	int index;
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
public:
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    41
	Indexer(): indexmap(), index(0) {};
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
	void reset() { indexmap.clear(); index = 0; };
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    43
	bool get(void *o, int &retidx);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    44
	const int &operator[](void *o) { return indexmap[o]; };
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    45
};
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    46
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    47
extern Indexer vertex_index, shape_index;
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    48
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    49
void resetSerializer();
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 78
diff changeset
    50
Shape *loadShape(istream &st, Material *mat);
78
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    51
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    52
ostream & operator<<(ostream &st, Shape &o);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    53
ostream & operator<<(ostream &st, Vertex &o);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    54
ostream & operator<<(ostream &st, Container &o);
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
    55
istream & operator>>(istream &st, Vector &v);
78
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    56
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    57
#endif