Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Step
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
Step
Commits
f1f5576f
Commit
f1f5576f
authored
Dec 19, 2014
by
Inge Wallin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate class Body from world.h and world.cc
parent
f836715f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
145 additions
and
64 deletions
+145
-64
stepcore/CMakeLists.txt
stepcore/CMakeLists.txt
+1
-0
stepcore/body.cc
stepcore/body.cc
+29
-0
stepcore/body.h
stepcore/body.h
+114
-0
stepcore/world.cc
stepcore/world.cc
+0
-1
stepcore/world.h
stepcore/world.h
+1
-63
No files found.
stepcore/CMakeLists.txt
View file @
f1f5576f
...
...
@@ -2,6 +2,7 @@
set
(
stepcore_SRCS
object.cc
constants.cc
body.cc
world.cc
solver.cc
collisionsolver.cc
...
...
stepcore/body.cc
0 → 100644
View file @
f1f5576f
/* This file is part of StepCore library.
Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
StepCore library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
StepCore library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with StepCore; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "body.h"
namespace
StepCore
{
STEPCORE_META_OBJECT
(
Body
,
QT_TRANSLATE_NOOP
(
"ObjectClass"
,
"Body"
),
QT_TR_NOOP
(
"Body"
),
MetaObject
::
ABSTRACT
,,)
}
// namespace StepCore
stepcore/body.h
0 → 100644
View file @
f1f5576f
/* This file is part of StepCore library.
Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
StepCore library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
StepCore library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with StepCore; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** \file world.h
* \brief Item, Body, Force and Tool interfaces, World class
*/
#ifndef STEPCORE_BODY_H
#define STEPCORE_BODY_H
#include <vector> // XXX: Replace if Qt is enabled.
#include "types.h"
#include "object.h"
namespace
StepCore
{
//class World;
//class Solver;
//class Item;
//class ItemGroup;
//class CollisionSolver;
//class ConstraintSolver;
/** \ingroup bodies
* \brief Interface for bodies
*
* Body is anything that has dynamic variables that require ODE integration
*/
class
Body
{
STEPCORE_OBJECT
(
Body
)
public:
Body
()
:
_variablesOffset
(
0
)
{}
virtual
~
Body
()
{}
/** Get count of dynamic variables (not including velocities) */
virtual
int
variablesCount
()
=
0
;
/** Set positions, velocities and (possibly) its variances using values in arrays and
* also reset accelerations and its variances. Variances should only be copied
* and reseted if positionVariance != NULL. */
virtual
void
setVariables
(
const
double
*
position
,
const
double
*
velocity
,
const
double
*
positionVariance
,
const
double
*
velocityVariance
)
=
0
;
/** Copy positions, velocities and (possibly) its variances to arrays.
* Variances should only be copied if positionVariance != NULL. */
virtual
void
getVariables
(
double
*
position
,
double
*
velocity
,
double
*
positionVariance
,
double
*
velocityVariance
)
=
0
;
/** Add force and (possibly) its variance to force accomulator.
* \note This function is used only by generic constraints handling code,
* force objects should use body-specific functions. */
virtual
void
addForce
(
const
double
*
force
,
const
double
*
forceVariance
)
=
0
;
/** Reset force accomulator and (possibly) its variance to zero.
* Variance should only be reseted if resetVariance == true. */
virtual
void
resetForce
(
bool
resetVariance
)
=
0
;
/** Copy acceleration (forces left-multiplied by inverse mass)
* and (possibly) its variances to arrays.
* Variances should only be copied if accelerationVariance != NULL. */
virtual
void
getAccelerations
(
double
*
acceleration
,
double
*
accelerationVariance
)
=
0
;
/** Get inverse mass and (possibly) its variance matrixes.
* Variance should only be copied of variance != NULL. */
virtual
void
getInverseMass
(
VectorXd
*
inverseMass
,
DynSparseRowMatrix
*
variance
,
int
offset
)
=
0
;
/** Offset of body's variables in global arrays
* (meaningless if the body is not a part of the world) */
int
variablesOffset
()
const
{
return
_variablesOffset
;
}
private:
friend
class
World
;
/** \internal Set offset of body's variables in global arrays */
void
setVariablesOffset
(
int
variablesOffset
)
{
_variablesOffset
=
variablesOffset
;
}
int
_variablesOffset
;
};
/** List of pointers to Body */
typedef
std
::
vector
<
Body
*>
BodyList
;
}
// namespace StepCore
#endif
stepcore/world.cc
View file @
f1f5576f
...
...
@@ -29,7 +29,6 @@ namespace StepCore
STEPCORE_META_OBJECT
(
Item
,
QT_TRANSLATE_NOOP
(
"ObjectClass"
,
"Item"
),
QT_TR_NOOP
(
"Item"
),
MetaObject
::
ABSTRACT
,
STEPCORE_SUPER_CLASS
(
Object
),
STEPCORE_PROPERTY_RW
(
StepCore
::
Color
,
color
,
QT_TRANSLATE_NOOP
(
"PropertyName"
,
"color"
),
STEPCORE_UNITS_NULL
,
QT_TR_NOOP
(
"Item color"
),
color
,
setColor
))
STEPCORE_META_OBJECT
(
Body
,
QT_TRANSLATE_NOOP
(
"ObjectClass"
,
"Body"
),
QT_TR_NOOP
(
"Body"
),
MetaObject
::
ABSTRACT
,,)
STEPCORE_META_OBJECT
(
Force
,
QT_TRANSLATE_NOOP
(
"ObjectClass"
,
"Force"
),
QT_TR_NOOP
(
"Force"
),
MetaObject
::
ABSTRACT
,,)
STEPCORE_META_OBJECT
(
Joint
,
QT_TRANSLATE_NOOP
(
"ObjectClass"
,
"Joint"
),
QT_TR_NOOP
(
"Joint"
),
MetaObject
::
ABSTRACT
,,)
STEPCORE_META_OBJECT
(
Tool
,
QT_TRANSLATE_NOOP
(
"ObjectClass"
,
"Tool"
),
QT_TR_NOOP
(
"Tool"
),
MetaObject
::
ABSTRACT
,,)
...
...
stepcore/world.h
View file @
f1f5576f
...
...
@@ -26,6 +26,7 @@
#include "types.h"
#include "util.h"
#include "object.h"
#include "body.h"
#include "vector.h"
#include <vector> // XXX: replace if QT is enabled
...
...
@@ -130,67 +131,6 @@ private:
Color
_color
;
};
/** \ingroup bodies
* \brief Interface for bodies
*
* Body is anything that has dynamic variables that require ODE integration
*/
class
Body
{
STEPCORE_OBJECT
(
Body
)
public:
Body
()
:
_variablesOffset
(
0
)
{}
virtual
~
Body
()
{}
/** Get count of dynamic variables (not including velocities) */
virtual
int
variablesCount
()
=
0
;
/** Set positions, velocities and (possibly) its variances using values in arrays and
* also reset accelerations and its variances. Variances should only be copied
* and reseted if positionVariance != NULL. */
virtual
void
setVariables
(
const
double
*
position
,
const
double
*
velocity
,
const
double
*
positionVariance
,
const
double
*
velocityVariance
)
=
0
;
/** Copy positions, velocities and (possibly) its variances to arrays.
* Variances should only be copied if positionVariance != NULL. */
virtual
void
getVariables
(
double
*
position
,
double
*
velocity
,
double
*
positionVariance
,
double
*
velocityVariance
)
=
0
;
/** Add force and (possibly) its variance to force accomulator.
* \note This function is used only by generic constraints handling code,
* force objects should use body-specific functions. */
virtual
void
addForce
(
const
double
*
force
,
const
double
*
forceVariance
)
=
0
;
/** Reset force accomulator and (possibly) its variance to zero.
* Variance should only be reseted if resetVariance == true. */
virtual
void
resetForce
(
bool
resetVariance
)
=
0
;
/** Copy acceleration (forces left-multiplied by inverse mass)
* and (possibly) its variances to arrays.
* Variances should only be copied if accelerationVariance != NULL. */
virtual
void
getAccelerations
(
double
*
acceleration
,
double
*
accelerationVariance
)
=
0
;
/** Get inverse mass and (possibly) its variance matrixes.
* Variance should only be copied of variance != NULL. */
virtual
void
getInverseMass
(
VectorXd
*
inverseMass
,
DynSparseRowMatrix
*
variance
,
int
offset
)
=
0
;
/** Offset of body's variables in global arrays
* (meaningless if the body is not a part of the world) */
int
variablesOffset
()
const
{
return
_variablesOffset
;
}
private:
friend
class
World
;
/** \internal Set offset of body's variables in global arrays */
void
setVariablesOffset
(
int
variablesOffset
)
{
_variablesOffset
=
variablesOffset
;
}
int
_variablesOffset
;
};
/** \ingroup forces
* \brief Interface for forces
*
...
...
@@ -296,8 +236,6 @@ public:
/** List of pointers to Item */
typedef
std
::
vector
<
Item
*>
ItemList
;
/** List of pointers to Body */
typedef
std
::
vector
<
Body
*>
BodyList
;
/** List of pointers to Force */
typedef
std
::
vector
<
Force
*>
ForceList
;
/** List of pointers to Joint */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment