~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/gameengine/Rasterizer/RAS_TexVert.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: RAS_TexVert.cpp,v 1.4 2004/03/22 22:02:13 jesterking Exp $
 
2
 * $Id: RAS_TexVert.cpp,v 1.9 2005/01/03 18:05:24 sirdude Exp $
3
3
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or
35
35
#include <config.h>
36
36
#endif
37
37
 
 
38
#define SHORT(x) short(x*32767.0)
 
39
 
38
40
RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
39
41
                                                 const MT_Point2& uv,
40
42
                                                 const unsigned int rgba,
41
 
                                                 const short *normal,
 
43
                                                 const MT_Vector3& normal,
42
44
                                                 const short flag) 
43
45
{
44
46
        xyz.getValue(m_localxyz);
45
47
        uv.getValue(m_uv1);
46
48
        SetRGBA(rgba);
47
 
        m_normal[0] = normal[0];
48
 
        m_normal[1] = normal[1];
49
 
        m_normal[2] = normal[2];
 
49
        SetNormal(normal);
50
50
        m_flag = flag;
51
51
}
52
52
 
53
 
 
54
 
 
55
 
 
56
 
 
57
53
const MT_Point3& RAS_TexVert::xyz()
58
54
{
59
55
        g_pt3.setValue(m_localxyz);
60
56
        return g_pt3;
61
57
}
62
58
 
 
59
void RAS_TexVert::SetRGBA(const MT_Vector4& rgba)
 
60
{
 
61
        unsigned char *colp = (unsigned char*) &m_rgba;
 
62
        colp[0] = (unsigned char) (rgba[0]*255.0);
 
63
        colp[1] = (unsigned char) (rgba[1]*255.0);
 
64
        colp[2] = (unsigned char) (rgba[2]*255.0);
 
65
        colp[3] = (unsigned char) (rgba[3]*255.0);
 
66
}
 
67
 
 
68
 
63
69
void RAS_TexVert::SetXYZ(const MT_Point3& xyz)
64
70
{
65
71
        xyz.getValue(m_localxyz);
86
92
}
87
93
void RAS_TexVert::SetNormal(const MT_Vector3& normal)
88
94
{
89
 
        m_normal[0] = short(normal.x()*32767.0);
90
 
        m_normal[1] = short(normal.y()*32767.0);
91
 
        m_normal[2] = short(normal.z()*32767.0);
 
95
        normal.getValue(m_normal);
92
96
}
93
97
 
94
 
 
95
98
#ifndef RAS_TexVert_INLINE
 
99
 
96
100
// leave multiline for debugging
97
101
const float* RAS_TexVert::getUV1 () const
98
102
{
100
104
}
101
105
 
102
106
 
103
 
const short* RAS_TexVert::getNormal() const
 
107
const float* RAS_TexVert::getNormal() const
104
108
{
105
109
        return m_normal;
106
110
}
107
111
 
108
 
 
109
 
 
110
112
const float* RAS_TexVert::getLocalXYZ() const
111
113
112
114
        return m_localxyz;
113
115
}
114
 
        
115
 
 
116
 
 
117
 
const unsigned int& RAS_TexVert::getRGBA() const
 
116
 
 
117
const unsigned char* RAS_TexVert::getRGBA() const
118
118
{
119
 
        return m_rgba;
 
119
        return (unsigned char*) &m_rgba;
120
120
}
121
121
 
122
122
#endif
124
124
// compare two vertices, and return TRUE if both are almost identical (they can be shared)
125
125
bool RAS_TexVert::closeTo(const RAS_TexVert* other)
126
126
{
127
 
        return ((MT_Vector3(m_localxyz) - MT_Vector3(other->m_localxyz)).fuzzyZero() &&
128
 
                (MT_Vector2(m_uv1) - MT_Vector2(other->m_uv1)).fuzzyZero() &&
129
 
                m_normal[0] == other->m_normal[0] &&
130
 
                m_normal[1] == other->m_normal[1] &&
131
 
                m_normal[2] == other->m_normal[2] &&
132
 
                m_flag == other->m_flag &&
133
 
                m_rgba == other->m_rgba) ;
 
127
        return (m_flag == other->m_flag &&
 
128
                m_rgba == other->m_rgba &&
 
129
                MT_fuzzyEqual(MT_Vector3(m_normal), MT_Vector3(other->m_normal)) &&
 
130
                MT_fuzzyEqual(MT_Vector2(m_uv1), MT_Vector2(other->m_uv1)) &&
 
131
                MT_fuzzyEqual(MT_Vector3(m_localxyz), MT_Vector3(other->m_localxyz))) ;
134
132
        
135
133
}
136
134
 
137
 
 
138
 
 
139
 
bool RAS_TexVert::closeTo(const MT_Point3& otherxyz,
140
 
                         const MT_Point2& otheruv,
141
 
                         const unsigned int otherrgba,
142
 
                         short othernormal[3]) const
143
 
{
144
 
        return ((MT_Vector3(m_localxyz) - otherxyz).fuzzyZero() &&
145
 
                (MT_Vector2(m_uv1) - otheruv).fuzzyZero() &&
146
 
                m_normal[0] == othernormal[0] &&
147
 
                m_normal[1] == othernormal[1] &&
148
 
                m_normal[2] == othernormal[2] &&
149
 
                m_rgba == otherrgba) ;
150
 
}
151
 
 
152
 
 
153
135
short RAS_TexVert::getFlag() const
154
136
{
155
137
        return m_flag;
159
141
{
160
142
        xyz = (void *) m_localxyz;
161
143
        uv1 = (void *) m_uv1;
162
 
        rgba = (void *) m_rgba;
 
144
        rgba = (void *) &m_rgba;
163
145
        normal = (void *) m_normal;
164
146
}