Commit e2f8a703 authored by lukeph's avatar lukeph

-B3D loader: support for different TRIS Chunks sharing the same vertex in static meshes.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@925 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 2da809bc
...@@ -524,6 +524,9 @@ bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *InJoint, scene::SSk ...@@ -524,6 +524,9 @@ bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *InJoint, scene::SSk
bool CB3DMeshFileLoader::readChunkTRIS(CSkinnedMesh::SJoint *InJoint, scene::SSkinMeshBuffer *MeshBuffer, u32 MeshBufferID, s32 Vertices_Start) bool CB3DMeshFileLoader::readChunkTRIS(CSkinnedMesh::SJoint *InJoint, scene::SSkinMeshBuffer *MeshBuffer, u32 MeshBufferID, s32 Vertices_Start)
{ {
bool showVertexWarning=false;
s32 triangle_brush_id; // Note: Irrlicht can't have different brushes for each triangle (I'm using a workaround) s32 triangle_brush_id; // Note: Irrlicht can't have different brushes for each triangle (I'm using a workaround)
file->read(&triangle_brush_id, sizeof(triangle_brush_id)); file->read(&triangle_brush_id, sizeof(triangle_brush_id));
...@@ -566,6 +569,15 @@ bool CB3DMeshFileLoader::readChunkTRIS(CSkinnedMesh::SJoint *InJoint, scene::SSk ...@@ -566,6 +569,15 @@ bool CB3DMeshFileLoader::readChunkTRIS(CSkinnedMesh::SJoint *InJoint, scene::SSk
for(s32 i=0; i<3; ++i) for(s32 i=0; i<3; ++i)
{ {
if (AnimatedVertices_VertexID[ vertex_id[i] ] != -1)
{
if ( AnimatedVertices_BufferID[ vertex_id[i] ] != (s32)MeshBufferID ) //If this vertex is linked in a different meshbuffer
{
AnimatedVertices_VertexID[ vertex_id[i] ] = -1;
AnimatedVertices_BufferID[ vertex_id[i] ] = -1;
showVertexWarning=true;
}
}
if (AnimatedVertices_VertexID[ vertex_id[i] ] == -1) //If this vertex is not in the meshbuffer if (AnimatedVertices_VertexID[ vertex_id[i] ] == -1) //If this vertex is not in the meshbuffer
{ {
...@@ -617,6 +629,11 @@ bool CB3DMeshFileLoader::readChunkTRIS(CSkinnedMesh::SJoint *InJoint, scene::SSk ...@@ -617,6 +629,11 @@ bool CB3DMeshFileLoader::readChunkTRIS(CSkinnedMesh::SJoint *InJoint, scene::SSk
B3dStack.erase(B3dStack.size()-1); B3dStack.erase(B3dStack.size()-1);
if (showVertexWarning)
os::Printer::log("B3dMeshLoader: Warning, different meshbuffers linking to the same vertex, this will cause problems with animated meshes");
return true; return true;
} }
......
...@@ -410,12 +410,12 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -410,12 +410,12 @@ bool CGUIEditBox::processKey(const SEvent& event)
if (event.KeyInput.Shift) if (event.KeyInput.Shift)
{ {
if (CursorPos > 0) if (CursorPos > 0)
{ {
if (MarkBegin == MarkEnd) if (MarkBegin == MarkEnd)
MarkBegin = CursorPos; MarkBegin = CursorPos;
MarkEnd = CursorPos-1; MarkEnd = CursorPos-1;
} }
} }
else else
...@@ -429,15 +429,15 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -429,15 +429,15 @@ bool CGUIEditBox::processKey(const SEvent& event)
break; break;
case KEY_RIGHT: case KEY_RIGHT:
if (event.KeyInput.Shift) if (event.KeyInput.Shift)
{ {
if (Text.size() > (u32)CursorPos) if (Text.size() > (u32)CursorPos)
{ {
if (MarkBegin == MarkEnd) if (MarkBegin == MarkEnd)
MarkBegin = CursorPos; MarkBegin = CursorPos;
MarkEnd = CursorPos+1; MarkEnd = CursorPos+1;
} }
} }
else else
{ {
...@@ -518,7 +518,7 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -518,7 +518,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
if (Text.size()) if (Text.size())
{ {
core::stringw s; core::stringw s;
if (MarkBegin != MarkEnd) if (MarkBegin != MarkEnd)
{ {
// delete marked text // delete marked text
...@@ -653,7 +653,7 @@ void CGUIEditBox::draw() ...@@ -653,7 +653,7 @@ void CGUIEditBox::draw()
{ {
skin->draw3DSunkenPane(this, skin->getColor(EGDC_WINDOW), skin->draw3DSunkenPane(this, skin->getColor(EGDC_WINDOW),
false, true, frameRect, &AbsoluteClippingRect); false, true, frameRect, &AbsoluteClippingRect);
frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
frameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; frameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1;
frameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1; frameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
...@@ -681,7 +681,7 @@ void CGUIEditBox::draw() ...@@ -681,7 +681,7 @@ void CGUIEditBox::draw()
core::stringw *txtLine = &Text; core::stringw *txtLine = &Text;
s32 startPos = 0; s32 startPos = 0;
core::stringw s, s2; core::stringw s, s2;
// get mark position // get mark position
bool ml = (!PasswordBox && (WordWrap || MultiLine)); bool ml = (!PasswordBox && (WordWrap || MultiLine));
...@@ -734,25 +734,25 @@ void CGUIEditBox::draw() ...@@ -734,25 +734,25 @@ void CGUIEditBox::draw()
startPos = 0; startPos = 0;
} }
else else
{ {
txtLine = ml ? &BrokenText[i] : &Text; txtLine = ml ? &BrokenText[i] : &Text;
startPos = ml ? BrokenTextPositions[i] : 0; startPos = ml ? BrokenTextPositions[i] : 0;
} }
// draw normal text // draw normal text
font->draw(txtLine->c_str(), CurrentTextRect, font->draw(txtLine->c_str(), CurrentTextRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
false, true, &localClipRect); false, true, &localClipRect);
// draw mark and marked text // draw mark and marked text
if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount) if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount)
{ {
s32 mbegin = 0, mend = 0; s32 mbegin = 0, mend = 0;
s32 lineStartPos = 0, lineEndPos = txtLine->size(); s32 lineStartPos = 0, lineEndPos = txtLine->size();
if (i == hlineStart) if (i == hlineStart)
{ {
// highlight start is on this line // highlight start is on this line
s = txtLine->subString(0, realmbgn - startPos); s = txtLine->subString(0, realmbgn - startPos);
...@@ -779,9 +779,9 @@ void CGUIEditBox::draw() ...@@ -779,9 +779,9 @@ void CGUIEditBox::draw()
s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos); s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos);
if (s.size()) if (s.size())
font->draw(s.c_str(), CurrentTextRect, font->draw(s.c_str(), CurrentTextRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT),
false, true, &localClipRect); false, true, &localClipRect);
} }
} }
...@@ -793,7 +793,7 @@ void CGUIEditBox::draw() ...@@ -793,7 +793,7 @@ void CGUIEditBox::draw()
// draw cursor // draw cursor
if (WordWrap || MultiLine) if (WordWrap || MultiLine)
{ {
cursorLine = getLineFromPos(CursorPos); cursorLine = getLineFromPos(CursorPos);
txtLine = &BrokenText[cursorLine]; txtLine = &BrokenText[cursorLine];
...@@ -807,7 +807,7 @@ void CGUIEditBox::draw() ...@@ -807,7 +807,7 @@ void CGUIEditBox::draw()
setTextRect(cursorLine); setTextRect(cursorLine);
CurrentTextRect.UpperLeftCorner.X += charcursorpos; CurrentTextRect.UpperLeftCorner.X += charcursorpos;
font->draw(L"_", CurrentTextRect, font->draw(L"_", CurrentTextRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
false, true, &localClipRect); false, true, &localClipRect);
} }
...@@ -862,7 +862,7 @@ core::dimension2di CGUIEditBox::getTextDimension() ...@@ -862,7 +862,7 @@ core::dimension2di CGUIEditBox::getTextDimension()
//! Sets the maximum amount of characters which may be entered in the box. //! Sets the maximum amount of characters which may be entered in the box.
//! \param max: Maximum amount of characters. If 0, the character amount is //! \param max: Maximum amount of characters. If 0, the character amount is
//! infinity. //! infinity.
void CGUIEditBox::setMax(s32 max) void CGUIEditBox::setMax(s32 max)
{ {
...@@ -941,7 +941,7 @@ bool CGUIEditBox::processMouse(const SEvent& event) ...@@ -941,7 +941,7 @@ bool CGUIEditBox::processMouse(const SEvent& event)
calculateScrollPos(); calculateScrollPos();
return true; return true;
} }
} }
} }
return false; return false;
...@@ -958,9 +958,9 @@ s32 CGUIEditBox::getCursorPos(s32 x, s32 y) ...@@ -958,9 +958,9 @@ s32 CGUIEditBox::getCursorPos(s32 x, s32 y)
u32 lineCount = 1; u32 lineCount = 1;
if (WordWrap || MultiLine) if (WordWrap || MultiLine)
lineCount = BrokenText.size(); lineCount = BrokenText.size();
core::stringw *txtLine; core::stringw *txtLine=0;
s32 startPos=0; s32 startPos=0;
x+=3; x+=3;
...@@ -985,12 +985,12 @@ s32 CGUIEditBox::getCursorPos(s32 x, s32 y) ...@@ -985,12 +985,12 @@ s32 CGUIEditBox::getCursorPos(s32 x, s32 y)
if (x < CurrentTextRect.UpperLeftCorner.X) if (x < CurrentTextRect.UpperLeftCorner.X)
x = CurrentTextRect.UpperLeftCorner.X; x = CurrentTextRect.UpperLeftCorner.X;
s32 idx = font->getCharacterFromPos(Text.c_str(), x - CurrentTextRect.UpperLeftCorner.X); s32 idx = font->getCharacterFromPos(Text.c_str(), x - CurrentTextRect.UpperLeftCorner.X);
// click was on or left of the line // click was on or left of the line
if (idx != -1) if (idx != -1)
return idx + startPos; return idx + startPos;
// click was off the right edge of the line, go to end. // click was off the right edge of the line, go to end.
return txtLine->size() + startPos; return txtLine->size() + startPos;
} }
...@@ -1148,19 +1148,19 @@ void CGUIEditBox::setTextRect(s32 line) ...@@ -1148,19 +1148,19 @@ void CGUIEditBox::setTextRect(s32 line)
// align to left edge // align to left edge
CurrentTextRect.UpperLeftCorner.X = 0; CurrentTextRect.UpperLeftCorner.X = 0;
CurrentTextRect.LowerRightCorner.X = d.Width; CurrentTextRect.LowerRightCorner.X = d.Width;
} }
switch (VAlign) switch (VAlign)
{ {
case EGUIA_CENTER: case EGUIA_CENTER:
// align to v centre // align to v centre
CurrentTextRect.UpperLeftCorner.Y = CurrentTextRect.UpperLeftCorner.Y =
(frameRect.getHeight()/2) - (lineCount*d.Height)/2 + d.Height*line; (frameRect.getHeight()/2) - (lineCount*d.Height)/2 + d.Height*line;
break; break;
case EGUIA_LOWERRIGHT: case EGUIA_LOWERRIGHT:
// align to bottom edge // align to bottom edge
CurrentTextRect.UpperLeftCorner.Y = CurrentTextRect.UpperLeftCorner.Y =
frameRect.getHeight() - lineCount*d.Height + d.Height*line; frameRect.getHeight() - lineCount*d.Height + d.Height*line;
break; break;
default: default:
...@@ -1184,7 +1184,7 @@ s32 CGUIEditBox::getLineFromPos(s32 pos) ...@@ -1184,7 +1184,7 @@ s32 CGUIEditBox::getLineFromPos(s32 pos)
return 0; return 0;
s32 i=0; s32 i=0;
while (i < (s32)BrokenTextPositions.size()) while (i < (s32)BrokenTextPositions.size())
{ {
if (BrokenTextPositions[i] > pos) if (BrokenTextPositions[i] > pos)
return i-1; return i-1;
...@@ -1225,7 +1225,7 @@ void CGUIEditBox::inputChar(wchar_t c) ...@@ -1225,7 +1225,7 @@ void CGUIEditBox::inputChar(wchar_t c)
Text = s; Text = s;
++CursorPos; ++CursorPos;
} }
BlinkStartTime = os::Timer::getTime(); BlinkStartTime = os::Timer::getTime();
MarkBegin = 0; MarkBegin = 0;
MarkEnd = 0; MarkEnd = 0;
...@@ -1257,7 +1257,7 @@ void CGUIEditBox::calculateScrollPos() ...@@ -1257,7 +1257,7 @@ void CGUIEditBox::calculateScrollPos()
core::stringw *txtLine = MultiLine ? &BrokenText[cursLine] : &Text; core::stringw *txtLine = MultiLine ? &BrokenText[cursLine] : &Text;
s32 cPos = MultiLine ? CursorPos - BrokenTextPositions[cursLine] : CursorPos; s32 cPos = MultiLine ? CursorPos - BrokenTextPositions[cursLine] : CursorPos;
s32 cStart = CurrentTextRect.UpperLeftCorner.X + HScrollPos + s32 cStart = CurrentTextRect.UpperLeftCorner.X + HScrollPos +
font->getDimension(txtLine->subString(0, cPos).c_str()).Width; font->getDimension(txtLine->subString(0, cPos).c_str()).Width;
s32 cEnd = cStart + font->getDimension(L"_ ").Width; s32 cEnd = cStart + font->getDimension(L"_ ").Width;
...@@ -1268,7 +1268,7 @@ void CGUIEditBox::calculateScrollPos() ...@@ -1268,7 +1268,7 @@ void CGUIEditBox::calculateScrollPos()
HScrollPos = cStart - frameRect.UpperLeftCorner.X; HScrollPos = cStart - frameRect.UpperLeftCorner.X;
else else
HScrollPos = 0; HScrollPos = 0;
// todo: adjust scrollbar // todo: adjust scrollbar
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment