1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This 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 files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
// Object, body, and world methods.
#include <ode/common.h>
#include <ode/threading_impl.h>
#include <ode/objects.h>
#include "config.h"
#include "objects.h"
#include "default_threading.h"
#include "threading_impl.h"
#include "matrix.h"
#include "util.h"
#define dWORLD_DEFAULT_GLOBAL_ERP REAL(0.2)
#if defined(dSINGLE)
#define dWORLD_DEFAULT_GLOBAL_CFM REAL(1e-5)
#elif defined(dDOUBLE)
#define dWORLD_DEFAULT_GLOBAL_CFM REAL(1e-10)
#else
#error dSINGLE or dDOUBLE must be defined
#endif
dObject::~dObject()
{
// Do nothing - a virtual destructor
}
dxAutoDisable::dxAutoDisable(void *):
idle_time(REAL(0.0)),
idle_steps(10),
average_samples(1), // Default is 1 sample => Instantaneous velocity
linear_average_threshold(REAL(0.01)*REAL(0.01)), // (magnitude squared)
angular_average_threshold(REAL(0.01)*REAL(0.01)) // (magnitude squared)
{
}
dxDampingParameters::dxDampingParameters(void *):
linear_scale(REAL(0.0)),
angular_scale(REAL(0.0)),
linear_threshold(REAL(0.01) * REAL(0.01)),
angular_threshold(REAL(0.01) * REAL(0.01))
{
}
dxQuickStepParameters::dxQuickStepParameters(void *):
num_iterations(20),
w(REAL(1.3))
{
}
dxContactParameters::dxContactParameters(void *):
max_vel(dInfinity),
min_depth(REAL(0.0))
{
}
dxWorld::dxWorld():
dBase(),
dxThreadingBase(),
firstbody(NULL),
firstjoint(NULL),
nb(0),
nj(0),
global_erp(dWORLD_DEFAULT_GLOBAL_ERP),
global_cfm(dWORLD_DEFAULT_GLOBAL_CFM),
adis(NULL),
body_flags(0),
islands_max_threads(dWORLDSTEP_THREADCOUNT_UNLIMITED),
wmem(NULL),
qs(NULL),
contactp(NULL),
dampingp(NULL),
max_angular_speed(dInfinity),
userdata(0)
{
dxThreadingBase::setThreadingDefaultImplProvider(this);
dSetZero (gravity, 4);
}
dxWorld::~dxWorld()
{
if (wmem)
{
wmem->CleanupWorldReferences(this);
wmem->Release();
}
}
void dxWorld::assignThreadingImpl(const dxThreadingFunctionsInfo *functions_info, dThreadingImplementationID threading_impl)
{
if (wmem != NULL)
{
// Free objects allocated with old threading
wmem->CleanupWorldReferences(this);
}
dxThreadingBase::assignThreadingImpl(functions_info, threading_impl);
}
dxWorldProcessContext *dxWorld::unsafeGetWorldProcessingContext() const
{
return wmem->GetWorldProcessingContext();
}
const dxThreadingFunctionsInfo *dxWorld::retrieveThreadingDefaultImpl(dThreadingImplementationID &out_defaultImpl)
{
out_defaultImpl = DefaultThreadingHolder::getDefaultThreadingImpl();
return DefaultThreadingHolder::getDefaultThreadingFunctions();
}
|