mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
minor tweaks
This commit is contained in:
parent
b431099f2f
commit
ae0eaf823b
@ -32,9 +32,8 @@ TypeHandle CollisionHandlerPusher::_type_handle;
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class ShoveData {
|
class ShoveData {
|
||||||
public:
|
public:
|
||||||
LVector3f _shove;
|
LVector3f _vector;
|
||||||
float _length;
|
float _length;
|
||||||
LVector3f _normalized_shove;
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -108,7 +107,7 @@ handle_entries() {
|
|||||||
|
|
||||||
typedef pvector<ShoveData> Shoves;
|
typedef pvector<ShoveData> Shoves;
|
||||||
Shoves shoves;
|
Shoves shoves;
|
||||||
|
|
||||||
Entries::const_iterator ei;
|
Entries::const_iterator ei;
|
||||||
for (ei = entries.begin(); ei != entries.end(); ++ei) {
|
for (ei = entries.begin(); ei != entries.end(); ++ei) {
|
||||||
CollisionEntry *entry = (*ei);
|
CollisionEntry *entry = (*ei);
|
||||||
@ -117,29 +116,39 @@ handle_entries() {
|
|||||||
|
|
||||||
if (!entry->has_into_surface_normal() ||
|
if (!entry->has_into_surface_normal() ||
|
||||||
!entry->has_into_depth()) {
|
!entry->has_into_depth()) {
|
||||||
|
#ifndef NDEBUG
|
||||||
if (collide_cat.is_debug()) {
|
if (collide_cat.is_debug()) {
|
||||||
collide_cat.debug()
|
collide_cat.debug()
|
||||||
<< "Cannot shove on " << *from_node << " for collision into "
|
<< "Cannot shove on " << *from_node << " for collision into "
|
||||||
<< *entry->get_into_node() << "; no normal/depth information.\n";
|
<< *entry->get_into_node() << "; no normal/depth information.\n";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Shove it just enough to clear the volume.
|
// Shove it just enough to clear the volume.
|
||||||
if (entry->get_into_depth() != 0.0f) {
|
if (entry->get_into_depth() != 0.0f) {
|
||||||
|
LVector3f normal = entry->get_into_surface_normal();
|
||||||
|
if (_horizontal) {
|
||||||
|
normal[2] = 0.0f;
|
||||||
|
}
|
||||||
|
// Just to be on the safe size, we normalize the normal
|
||||||
|
// vector, even though it really out to be unit-length
|
||||||
|
// already (unless we just forced it horizontal, above).
|
||||||
|
normal.normalize();
|
||||||
|
|
||||||
ShoveData sd;
|
ShoveData sd;
|
||||||
sd._shove =
|
sd._vector = normal;
|
||||||
entry->get_into_surface_normal() *
|
sd._length = entry->get_into_depth();
|
||||||
entry->get_into_depth();
|
sd._valid = true;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
if (collide_cat.is_debug()) {
|
if (collide_cat.is_debug()) {
|
||||||
collide_cat.debug()
|
collide_cat.debug()
|
||||||
<< "Shove on " << *from_node << " from "
|
<< "Shove on " << *from_node << " from "
|
||||||
<< *entry->get_into_node() << ": " << sd._shove << "\n";
|
<< *entry->get_into_node() << ": " << sd._vector
|
||||||
|
<< " times " << sd._length << "\n";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
sd._length = sd._shove.length();
|
|
||||||
sd._normalized_shove = sd._shove / sd._length;
|
|
||||||
sd._valid = true;
|
|
||||||
|
|
||||||
shoves.push_back(sd);
|
shoves.push_back(sd);
|
||||||
}
|
}
|
||||||
@ -149,7 +158,7 @@ handle_entries() {
|
|||||||
if (!shoves.empty()) {
|
if (!shoves.empty()) {
|
||||||
// Now we combine any two shoves that shove in largely the
|
// Now we combine any two shoves that shove in largely the
|
||||||
// same direction. Hacky.
|
// same direction. Hacky.
|
||||||
|
|
||||||
Shoves::iterator si;
|
Shoves::iterator si;
|
||||||
for (si = shoves.begin(); si != shoves.end(); ++si) {
|
for (si = shoves.begin(); si != shoves.end(); ++si) {
|
||||||
ShoveData &sd = (*si);
|
ShoveData &sd = (*si);
|
||||||
@ -158,7 +167,7 @@ handle_entries() {
|
|||||||
ShoveData &sd2 = (*sj);
|
ShoveData &sd2 = (*sj);
|
||||||
if (sd2._valid) {
|
if (sd2._valid) {
|
||||||
|
|
||||||
float d = sd._normalized_shove.dot(sd2._normalized_shove);
|
float d = sd._vector.dot(sd2._vector);
|
||||||
if (collide_cat.is_debug()) {
|
if (collide_cat.is_debug()) {
|
||||||
collide_cat.debug()
|
collide_cat.debug()
|
||||||
<< "Considering dot product " << d << "\n";
|
<< "Considering dot product " << d << "\n";
|
||||||
@ -182,19 +191,17 @@ handle_entries() {
|
|||||||
for (si = shoves.begin(); si != shoves.end(); ++si) {
|
for (si = shoves.begin(); si != shoves.end(); ++si) {
|
||||||
const ShoveData &sd = (*si);
|
const ShoveData &sd = (*si);
|
||||||
if (sd._valid) {
|
if (sd._valid) {
|
||||||
net_shove += sd._shove;
|
net_shove += sd._vector * sd._length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_horizontal) {
|
#ifndef NDEBUG
|
||||||
net_shove[2] = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (collide_cat.is_debug()) {
|
if (collide_cat.is_debug()) {
|
||||||
collide_cat.debug()
|
collide_cat.debug()
|
||||||
<< "Net shove on " << *from_node << " is: "
|
<< "Net shove on " << *from_node << " is: "
|
||||||
<< net_shove << "\n";
|
<< net_shove << "\n";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LMatrix4f mat;
|
LMatrix4f mat;
|
||||||
def.get_mat(mat);
|
def.get_mat(mat);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user