Fixed: Removing some nlinfo and correction getMouseRightDown

This commit is contained in:
ulukyn 2016-12-13 21:08:33 +01:00
parent 2a7615b2f4
commit 448da5375d
5 changed files with 40 additions and 42 deletions

View file

@ -2011,7 +2011,6 @@ namespace NLGUI
it = styles.find("background-image");
if (it != styles.end())
{
nlinfo("found background-image %s", it->second.c_str());
string image = (*it).second;
string::size_type texExt = toLower(image).find("url(");
// Url image

View file

@ -1046,7 +1046,7 @@ void CClientConfig::setValues()
/////////////////////////
// NEW PATCHING SYSTEM //
READ_BOOL_DEV(PatchWanted)
READ_BOOL_FV(PatchWanted)
#ifdef RZ_USE_CUSTOM_PATCH_SERVER
READ_STRING_FV(PatchUrl)

View file

@ -548,7 +548,6 @@ CShapeInstanceReference CEntityManager::createInstance(const string& shape, cons
if (_LastRemovedInstance != -1)
{
idx = _LastRemovedInstance;
nlinfo("OK adding to index : %d", idx);
_ShapeInstances[idx].Instance = instance;
_ShapeInstances[idx].Primitive = primitive;
_ShapeInstances[idx].ContextText = text;
@ -562,7 +561,6 @@ CShapeInstanceReference CEntityManager::createInstance(const string& shape, cons
}
else
{
nlinfo("OK url, text = %s, %s", url.c_str(), text.c_str());
CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, !text.empty() || !url.empty());
instref.Primitive = primitive;
idx = _ShapeInstances.size();
@ -585,11 +583,15 @@ bool CEntityManager::deleteInstance(uint32 idx)
{
PACS->removePrimitive(primitive);
}
_ShapeInstances[idx].Primitive = NULL;
_ShapeInstances[idx].Deleted = true;
_ShapeInstances[idx].LastDeleted = _LastRemovedInstance;
_LastRemovedInstance = idx;
if (!_ShapeInstances[idx].Deleted)
{
_ShapeInstances[idx].Primitive = NULL;
_ShapeInstances[idx].Deleted = true;
_ShapeInstances[idx].LastDeleted = _LastRemovedInstance;
_LastRemovedInstance = idx;
}
return true;
}
@ -741,8 +743,6 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
for (uint32 i=0; i < keys.size(); i++)
{
nlinfo("Setup [%s] with [%s]", keys[i].c_str(), values[i].c_str());
string param = keys[i];
if (param == "transparency")
{
@ -915,15 +915,23 @@ CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float
//= _ShapeInstances[i].SelectionBox;
if(!_ShapeInstances[i].Instance.empty()) {
_ShapeInstances[i].Instance.getShapeAABBox(bbox);
CVector bbox_min;
CVector bbox_max;
if (bbox.getCenter() == CVector::Null)
{
bbox.setMinMax(CVector(-0.3f, -0.3f, -0.3f)+_ShapeInstances[i].Instance.getPos(), CVector(0.3f, 0.3f, 0.3f)+_ShapeInstances[i].Instance.getPos());
bbox_min = CVector(-0.5f, -0.5f, -0.5f);
bbox_max = CVector(-0.5f, -0.5f, -0.5f);
}
else
{
bbox.setMinMax((bbox.getMin()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox.getMax()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos());
bbox_min = bbox.getMin();
bbox_max = bbox.getMax();
}
if(bbox.intersect(pos, pos+dir*50.0f))
bbox.setMinMax((bbox_min*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox_max*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos());
if(bbox.intersect(pos, pos+dir*100.0f))
{
float dist = (bbox.getCenter()-pos).norm();
if (dist < bestDist)

View file

@ -1204,8 +1204,20 @@ int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls)
uint32 x = (uint32)ls.toInteger(1);
uint32 y = (uint32)ls.toInteger(2);
uint32 w, h;
CViewRenderer &viewRender = *CViewRenderer::getInstance();
viewRender.getScreenSize(w, h);
if(x >= w || y >= h) {
ls.push(-1);
return 1;
}
float cursX = (float)x/(float)w;
float cursY = (float)y/(float)h;
sint32 instance_idx;
EntitiesMngr.getShapeInstanceUnderPos(x, y, instance_idx);
EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx);
ls.push(instance_idx);
return 1;
@ -2177,7 +2189,6 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
UMovePrimitive *primitive = instref.Primitive;
if (primitive)
{
nlinfo("ok");
NLMISC::CAABBox bbox;
instance.getShapeAABBox(bbox);
@ -2188,11 +2199,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
primitive->setPrimitiveType(UMovePrimitive::_2DOrientedBox);
primitive->setSize((bbox.getMax().x - bbox.getMin().x)*scale, (bbox.getMax().y - bbox.getMin().y)*scale);
primitive->setHeight((bbox.getMax().z - bbox.getMin().z)*scale);
//primitive->setSize(9.0f, 9.0f);
//primitive->setHeight(12.0f);
nlinfo("%f, %f, %f", (bbox.getMax().x - bbox.getMin().x)*scale, (bbox.getMax().y - bbox.getMin().y)*scale, (bbox.getMax().z - bbox.getMin().z)*scale );
primitive->setCollisionMask(MaskColPlayer | MaskColNpc | MaskColDoor);
primitive->setOcclusionMask(MaskColPlayer | MaskColNpc | MaskColDoor);
primitive->setObstacle(true);

View file

@ -202,7 +202,7 @@ void CTool::getMouseRightDown(bool &down, sint32 &x, sint32 &y)
x = y = -1;
return;
}
down = cursor->getPointerMiddleDown(x, y);
down = cursor->getPointerRightDown(x, y);
}
@ -372,7 +372,6 @@ bool CTool::raytrace(const NLMISC::CVector &segmentStart, const NLMISC::CVector
{
if (Landscape)
{
nlinfo("landscape=%d,%d", segmentStart.x, segmentStart.y);
// use a shortest distance for collision manager (for speed)
CVector segmentEnd = segmentStart + 100.f * dir;
float dist = Landscape->getRayCollision(segmentStart, segmentEnd);
@ -485,27 +484,19 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
const CScenarioEntryPoints::CCompleteIsland *islandDesc = getEditor().getIslandCollision().getCurrIslandDesc();
if (!islandDesc) return false;
nlinfo("have island");
sint mapX = (sint) (x - islandDesc->XMin);
sint mapY = (sint) (y - islandDesc->YMin);
nlinfo("mapX,mapY=%d,%d island=%d,%d-%d,%d", mapX, mapY, islandDesc->XMin, islandDesc->YMin, islandDesc->XMax, islandDesc->YMax);
if (mapX < 0 || mapY < 0 || mapX >= (islandDesc->XMax - islandDesc->XMin) || mapY >= (islandDesc->YMax - islandDesc->YMin)) return false;
sint hmZ = heightMap(mapX, mapY);
nlinfo("HeightMap = %d", hmZ);
if (hmZ >= 0x7ffe) return false; // not an accessible pos
nlinfo("accessible pos");
if (!isIslandValidPos(heightMap, *islandDesc, x + 0.5f, y) ||
!isIslandValidPos(heightMap, *islandDesc, x - 0.5f, y) ||
!isIslandValidPos(heightMap, *islandDesc, x, y + 0.5f) ||
!isIslandValidPos(heightMap, *islandDesc, x, y - 0.5f)) return false;
nlinfo("valid pos");
float z = 1.f + 2.f * hmZ;
// this is a possibly valid position
// compute nearest surface from here, and see if not far from the intersection
@ -524,9 +515,7 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
inter1Found = inter1Found && normal1.z >= minAngleSin;
inter2Found = inter2Found && normal2.z >= minAngleSin;
if (!inter1Found && !inter2Found) return false;
nlinfo("inter foud");
if (inter1Found && inter2Found)
{
// because z in heightmap in usually a 'ceil' of real height, tends to favor surface below
@ -543,7 +532,6 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
{
inter = inter2;
}
nlinfo("inter = %d,%d", inter.x, inter.y);
return true;
}
@ -573,7 +561,6 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
{
CVector delta = bias * (cardinals[k].x * worldViewRay.Right + cardinals[k].y * worldViewRay.Up);
found = raytrace(worldViewRay.Origin + delta, worldViewRay.Dir, inter);
nlinfo("found");
}
if (!found)
{
@ -585,12 +572,10 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
const CArray2D<sint16> &heightMap = getEditor().getIslandCollision().getHeightMap();
if (!heightMap.empty())
{
nlinfo("okidoi : %d, %d", inter.x, inter.y);
// if heightmap is present, use it because it gives us more reliable information
CVector surfPos;
if (!computeNearestValidSurfaceFromHeightMap(inter.x, inter.y, surfPos)) return InvalidPacsPos;
static volatile float threshold = 2.f;
nlinfo("found");
return (inter - surfPos).norm() < threshold ? ValidPacsPos : InvalidPacsPos;
}
@ -601,7 +586,6 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
}
else
{
nlinfo("GR");
// see if pacs collisions are ok at that pos
NLPACS::UGlobalPosition dummyPos;
return getPacsType(inter, 2.f, dummyPos);