Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Niflib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grant Kim
Niflib
Commits
f26f9276
Commit
f26f9276
authored
16 years ago
by
Tazpn
Browse files
Options
Downloads
Patches
Plain Diff
niflib: Fix copy/paste issue with indices on InertiaMatrix
parent
0488eec5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/nif_math.h
+5
-1
5 additions, 1 deletion
include/nif_math.h
src/nif_math.cpp
+8
-8
8 additions, 8 deletions
src/nif_math.cpp
with
13 additions
and
9 deletions
include/nif_math.h
+
5
−
1
View file @
f26f9276
...
...
@@ -16,6 +16,10 @@ namespace Niflib {
#define PI 3.14159265358979323846f //Probably more accurate than a float can be, but it will just be rounded off anyway
#endif
#ifndef _countof
#define _countof(x) ((sizeof (x))/(sizeof((x)[0])))
#endif
//Forward declarations
struct
TexCoord
;
struct
Triangle
;
...
...
@@ -1065,7 +1069,7 @@ struct InertiaMatrix {
/*! Copy constructor. Initializes Matrix to another InertiaMatrix.
* \param[in] m The matrix to initialize this one to.
*/
NIFLIB_API
InertiaMatrix
(
const
InertiaMatrix
&
m
)
{
memcpy
(
rows
,
m
.
rows
,
sizeof
(
Float4
)
*
4
);
}
NIFLIB_API
InertiaMatrix
(
const
InertiaMatrix
&
m
)
{
memcpy
(
rows
,
m
.
rows
,
sizeof
(
Float4
)
*
_countof
(
rows
)
);
}
/*! This constructor can be used to set all values in this matrix during initialization
* \param[in] m11 The value to set at row 1, column 1.
...
...
This diff is collapsed.
Click to expand it.
src/nif_math.cpp
+
8
−
8
View file @
f26f9276
...
...
@@ -684,7 +684,7 @@ InertiaMatrix & InertiaMatrix::operator*=( const InertiaMatrix & rh ) {
InertiaMatrix
r
;
InertiaMatrix
&
lh
=
*
this
;
float
t
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
i
=
0
;
i
<
_countof
(
rows
)
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
t
=
0.0
f
;
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
...
...
@@ -703,7 +703,7 @@ InertiaMatrix InertiaMatrix::operator*( float rh ) const {
}
InertiaMatrix
&
InertiaMatrix
::
operator
*=
(
float
rh
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
i
=
0
;
i
<
_countof
(
rows
)
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
(
*
this
)[
i
][
j
]
*=
rh
;
}
...
...
@@ -726,7 +726,7 @@ InertiaMatrix InertiaMatrix::operator+( const InertiaMatrix & rh ) const {
}
InertiaMatrix
&
InertiaMatrix
::
operator
+=
(
const
InertiaMatrix
&
rh
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
i
=
0
;
i
<
_countof
(
rows
)
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
(
*
this
)[
i
][
j
]
+=
rh
[
i
][
j
];
}
...
...
@@ -735,12 +735,12 @@ InertiaMatrix & InertiaMatrix::operator+=( const InertiaMatrix & rh ) {
}
InertiaMatrix
&
InertiaMatrix
::
operator
=
(
const
InertiaMatrix
&
rh
)
{
memcpy
(
rows
,
rh
.
rows
,
sizeof
(
Float4
)
*
4
);
memcpy
(
rows
,
rh
.
rows
,
sizeof
(
Float4
)
*
_countof
(
rows
)
);
return
*
this
;
}
bool
InertiaMatrix
::
operator
==
(
const
InertiaMatrix
&
rh
)
const
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
i
=
0
;
i
<
_countof
(
rows
)
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
if
(
(
*
this
)[
i
][
j
]
!=
rh
[
i
][
j
]
)
return
false
;
...
...
@@ -750,7 +750,7 @@ bool InertiaMatrix::operator==( const InertiaMatrix & rh ) const {
}
bool
InertiaMatrix
::
operator
!=
(
const
InertiaMatrix
&
rh
)
const
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
i
=
0
;
i
<
_countof
(
rows
)
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
if
(
(
*
this
)[
i
][
j
]
!=
rh
[
i
][
j
]
)
return
true
;
...
...
@@ -769,7 +769,7 @@ InertiaMatrix InertiaMatrix::Transpose() const {
Matrix33
InertiaMatrix
::
Submatrix
(
int
skip_r
,
int
skip_c
)
const
{
Matrix33
sub
;
int
i
=
0
,
j
=
0
;
for
(
int
r
=
0
;
r
<
3
;
r
++
)
{
for
(
int
r
=
0
;
r
<
_countof
(
rows
)
;
r
++
)
{
if
(
r
==
skip_r
)
continue
;
for
(
int
c
=
0
;
c
<
4
;
c
++
)
{
...
...
@@ -793,7 +793,7 @@ InertiaMatrix InertiaMatrix::Inverse() const {
InertiaMatrix
result
;
float
det
=
Determinant
();
for
(
int
r
=
0
;
r
<
3
;
r
++
)
{
for
(
int
r
=
0
;
r
<
_countof
(
rows
)
;
r
++
)
{
for
(
int
c
=
0
;
c
<
4
;
c
++
)
{
result
[
c
][
r
]
=
Adjoint
(
r
,
c
)
/
det
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment