MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / correct_spawn_pos

Method correct_spawn_pos

ogsr_engine/xrGame/PhysicsShellHolder.cpp:103–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 m_collide_snd_dist = {-1.f, -1.f};
102}
103void CPhysicsShellHolder::correct_spawn_pos()
104{
105 VERIFY(PPhysicsShell());
106
107 Fvector size;
108 Fvector c;
109 get_box(PPhysicsShell(), XFORM(), size, c);
110
111 CPHActivationShape activation_shape;
112 activation_shape.Create(c, size, this);
113 activation_shape.set_rotation(XFORM());
114 PPhysicsShell()->DisableCollision();
115 activation_shape.Activate(size, 1, 1.f, M_PI / 8.f);
116 //// VERIFY (valid_pos(activation_shape.Position(),phBoundaries));
117 // if (!valid_pos(activation_shape.Position(),phBoundaries)) {
118 // CPHActivationShape activation_shape;
119 // activation_shape.Create (c,size,this);
120 // activation_shape.set_rotation (XFORM());
121 // activation_shape.Activate (size,1,1.f,M_PI/8.f);
122 //// VERIFY (valid_pos(activation_shape.Position(),phBoundaries));
123 // }
124
125 PPhysicsShell()->EnableCollision();
126
127 Fvector ap = activation_shape.Position();
128#ifdef DEBUG
129 if (!valid_pos(ap, phBoundaries))
130 {
131 Msg("not valid position %f,%f,%f", ap.x, ap.y, ap.z);
132 Msg("size %f,%f,%f", size.x, size.y, size.z);
133 Msg("Object: %s", Name());
134 Msg("Visual: %s", *(cNameVisual()));
135 Msg("Object pos %f,%f,%f", Position().x, Position().y, Position().z);
136 }
137#endif // DEBUG
138 VERIFY(valid_pos(activation_shape.Position(), phBoundaries));
139
140 Fmatrix trans;
141 trans.identity();
142 trans.c.sub(ap, c);
143 PPhysicsShell()->TransformPosition(trans);
144 PPhysicsShell()->GetGlobalTransformDynamic(&XFORM());
145 activation_shape.Destroy();
146}
147
148void CPhysicsShellHolder::activate_physic_shell()
149{

Callers

nothing calls this directly

Calls 15

get_boxFunction · 0.85
XFORMFunction · 0.85
valid_posFunction · 0.85
MsgFunction · 0.85
DisableCollisionMethod · 0.80
EnableCollisionMethod · 0.80
PositionMethod · 0.80
NameFunction · 0.50
CreateMethod · 0.45
set_rotationMethod · 0.45
ActivateMethod · 0.45
identityMethod · 0.45

Tested by

no test coverage detected