Revision: 19615
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19615
Author:   campbellbarton
Date:     2009-04-09 11:50:17 +0200 (Thu, 09 Apr 2009)

Log Message:
-----------
BGE Text
- multi-line strings for bitmap text 
- keyboard sensor now logs return and pad enter as "\n"

BGE std::vector use in Value.cpp and RAS_MaterialBucket.cpp
The size of a new list is known before making them, reduce re-allocs, though 
probably not a noticeable speedup.

Modified Paths:
--------------
    trunk/blender/source/blender/gpu/intern/gpu_draw.c
    trunk/blender/source/gameengine/Expressions/Value.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
    trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp

Modified: trunk/blender/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_draw.c  2009-04-09 07:26:49 UTC 
(rev 19614)
+++ trunk/blender/source/blender/gpu/intern/gpu_draw.c  2009-04-09 09:50:17 UTC 
(rev 19615)
@@ -84,6 +84,15 @@
                int characters, index, character;
                float centerx, centery, sizex, sizey, transx, transy, movex, 
movey, advance;
 
+               /* multiline */
+               float line_start= 0.0f, line_height; 
+               if (v4)
+                       line_height= MAX4(v1[1], v2[1], v3[1], v4[2]) - 
MIN4(v1[1], v2[1], v3[1], v4[2]);
+               else
+                       line_height= MAX3(v1[1], v2[1], v3[1]) - MIN3(v1[1], 
v2[1], v3[1]);
+               line_height *= 1.2; /* could be an option? */
+               /* end multiline */
+               
                characters = textlen;
 
                ima = (Image*)tface->tpage;
@@ -97,12 +106,19 @@
                        glColor3f(1.0f, 1.0f, 1.0f);
 
                glPushMatrix();
+               
                for (index = 0; index < characters; index++) {
                        float uv[4][2];
 
                        // lets calculate offset stuff
                        character = textstr[index];
                        
+                       if (character=='\n') {
+                               glTranslatef(line_start, -line_height, 0.0);
+                               line_start = 0.0f;
+                               continue;
+                       }
+                       
                        // space starts at offset 1
                        // character = character - ' ' + 1;
                        matrixGlyph((ImBuf *)ima->ibufs.first, character, & 
centerx, &centery,
@@ -143,6 +159,7 @@
                        glEnd();
 
                        glTranslatef(advance, 0.0, 0.0);
+                       line_start -= advance; /* so we can go back to the 
start of the line */
                }
                glPopMatrix();
        }

Modified: trunk/blender/source/gameengine/Expressions/Value.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/Value.cpp       2009-04-09 
07:26:49 UTC (rev 19614)
+++ trunk/blender/source/gameengine/Expressions/Value.cpp       2009-04-09 
09:50:17 UTC (rev 19615)
@@ -436,6 +436,8 @@
 {
        vector<STR_String> result;
        if(!m_pNamedPropertyArray) return result;
+       result.reserve(m_pNamedPropertyArray->size());
+       
        std::map<STR_String,CValue*>::iterator it;
        for (it= m_pNamedPropertyArray->begin(); (it != 
m_pNamedPropertyArray->end()); it++)
        {

Modified: trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp    
2009-04-09 07:26:49 UTC (rev 19614)
+++ trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp    
2009-04-09 09:50:17 UTC (rev 19615)
@@ -376,7 +376,8 @@
                 || ((keyIndex >= SCA_IInputDevice::KX_AKEY) 
                         && (keyIndex <= SCA_IInputDevice::KX_ZKEY)) 
                 || (keyIndex == SCA_IInputDevice::KX_SPACEKEY) 
-/*                      || (keyIndex == KX_RETKEY)  */
+                || (keyIndex == SCA_IInputDevice::KX_RETKEY)
+                || (keyIndex == SCA_IInputDevice::KX_PADENTER)
                 || (keyIndex == SCA_IInputDevice::KX_PADASTERKEY) 
                 || (keyIndex == SCA_IInputDevice::KX_TABKEY) 
                 || ((keyIndex >= SCA_IInputDevice::KX_COMMAKEY) 
@@ -386,7 +387,7 @@
                 || ((keyIndex >= SCA_IInputDevice::KX_PAD2) 
                         && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY)) 
                 || (keyIndex == SCA_IInputDevice::KX_DELKEY)
-                || (keyIndex == SCA_IInputDevice::KX_BACKSPACEKEY)             
                 
+                || (keyIndex == SCA_IInputDevice::KX_BACKSPACEKEY)
                )
        {
                return true;
@@ -423,8 +424,10 @@
        if (keyIndex == SCA_IInputDevice::KX_SPACEKEY) {
                return ' ';
        }
+       if (keyIndex == SCA_IInputDevice::KX_RETKEY || keyIndex == 
SCA_IInputDevice::KX_PADENTER) {
+               return '\n';
+       }
        
-/*                      || (keyIndex == SCA_IInputDevice::KX_RETKEY)  */
        
        if (keyIndex == SCA_IInputDevice::KX_PADASTERKEY) {
                return '*';

Modified: trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
===================================================================
--- trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp   
2009-04-09 07:26:49 UTC (rev 19614)
+++ trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp   
2009-04-09 09:50:17 UTC (rev 19615)
@@ -330,6 +330,9 @@
        for(begin(mit); !end(mit); next(mit))
                for(i=mit.startvertex; i<mit.endvertex; i++)
                        mit.vertex[i].Transform(transform, ntransform);
+       
+       /* We know we'll need a list at least this big, reserve in advance */
+       target->m_displayArrays.reserve(target->m_displayArrays.size() + 
m_displayArrays.size());
 
        for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
                target->m_displayArrays.push_back(*it);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to