Copy the data from the user into the height-field array
| 87 | |
| 88 | // Copy the data from the user into the height-field array |
| 89 | void HeightField::copyData(const void* heightFieldData) { |
| 90 | |
| 91 | // For each height value |
| 92 | for (uint32 x=0; x < mNbColumns; x++) { |
| 93 | |
| 94 | for (uint32 y=0; y < mNbRows; y++) { |
| 95 | |
| 96 | decimal height = 0.0; |
| 97 | |
| 98 | switch(mHeightDataType) { |
| 99 | case HeightDataType::HEIGHT_FLOAT_TYPE: |
| 100 | height = decimal(((float*)heightFieldData)[y * mNbColumns + x]); |
| 101 | break; |
| 102 | case HeightDataType::HEIGHT_DOUBLE_TYPE: |
| 103 | height = decimal(((double*)heightFieldData)[y * mNbColumns + x]); |
| 104 | break; |
| 105 | case HeightDataType::HEIGHT_INT_TYPE: |
| 106 | height = decimal(((int*)heightFieldData)[y * mNbColumns + x] * mIntegerHeightScale); |
| 107 | break; |
| 108 | default: |
| 109 | assert(false); // This should never happen |
| 110 | } |
| 111 | |
| 112 | mHeightFieldData[y * mNbColumns + x] = height; |
| 113 | |
| 114 | if (x == 0 && y == 0) { |
| 115 | mMinHeight = height; |
| 116 | mMaxHeight = height; |
| 117 | } |
| 118 | |
| 119 | // Compute minimum height |
| 120 | if (height < mMinHeight) { |
| 121 | mMinHeight = height; |
| 122 | } |
| 123 | |
| 124 | // Compute maximum height |
| 125 | if (height > mMaxHeight) { |
| 126 | mMaxHeight = height; |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | // Compute the height origin |
| 132 | mHeightOrigin = -(mMaxHeight - mMinHeight) * decimal(0.5) - mMinHeight; |
| 133 | } |
| 134 | |
| 135 | // Test collision with the triangles of the height field shape. The idea is to use the AABB |
| 136 | // of the body when need to test and see against which triangles of the height-field we need |
nothing calls this directly
no outgoing calls
no test coverage detected